Selective application of sample padding in adaptive loop filtering

ABSTRACT

An example method of video processing includes making a first determination, for a conversion between a current block of a video and a bitstream representation of the video, about whether a sample in a neighboring block of the current block is in a same video region as the current block and using the first determination to make a second determination about applicability of a coding tool that uses samples outside the current block to the conversion of the current block. The coding tool comprises an adaptive loop filter (ALF) tool that comprises an ALF classification process and/or an ALF filtering process. The method also includes performing the conversion according to the first determination and the second determination.

CROSS REFERENCE TO RELATED APPLICATIONS

This application is a continuation of International Patent ApplicationNo. PCT/CN2020/116708, filed on Sep. 22, 2020, which claims the priorityto and benefits of International Patent Application No.PCT/CN2019/107160, filed on Sep. 22, 2019. All the aforementioned patentapplications are hereby incorporated by reference in their entireties.

TECHNICAL FIELD

This patent document is directed generally to video coding and decodingtechnologies.

BACKGROUND

Video coding standards have evolved primarily through the development ofthe well-known ITU-T and ISO/IEC standards. The ITU-T produced H.261 andH.263, ISO/IEC produced MPEG-1 and MPEG-4 Visual, and the twoorganizations jointly produced the H.262/MPEG-2 Video and H.264/MPEG-4Advanced Video Coding (AVC) and H.265/High Efficiency Video Coding(HEVC) standards. Since H.262, the video coding standards are based onthe hybrid video coding structure wherein temporal prediction plustransform coding are utilized. To explore the future video codingtechnologies beyond HEVC, Joint Video Exploration Team (JVET) wasfounded by VCEG and MPEG jointly in 2015. Since then, many new methodshave been adopted by JVET and put into the referencesoftwarenamedJointExploration Model (JEM). In April 2018, the JVETbetween VCEG (Q6/16) and ISO/IEC JTC1 SC29/WG11 (MPEG) was created towork on the next generation Versatile Video Coding (VVC) standardtargeting at 50% bitrate reduction compared to HEVC.

SUMMARY

Using the disclosed video coding, transcoding or decoding techniques,embodiments of video encoders or decoders can handle virtual boundariesof coding tree blocks to provide better compression efficiency andsimpler implementations of coding or decoding tools.

In one example aspect, a method of video processing is disclosed. Themethod includes determining, for a conversion between a current block ofa video and a bitstream representation of the video, that one or moresamples of the video outside the current block are unavailable for acoding process of the conversion. The coding process comprises anadaptive loop filter (ALF) coding process. The method includesperforming, based on the determining, the conversion by using paddedsamples for the one or more samples of the video. The padded samples aregenerated by checking for availability of samples in an order.

In another example aspect, a method of video processing is disclosed.The method includes making a first determination, for a conversionbetween a current block of a video and a bitstream representation of thevideo, about whether a sample in a neighboring block of the currentblock is in a same video region as the current block. The neighboringblock is located (1) above and to the left of the current block, (2)above and to the right of the current block, (3) below and to the leftof the current block, or (4) below and to the right of the currentblock. The method includes using the first determination to make asecond determination about applicability of a coding tool that usessamples outside the current block to the conversion of the currentblock. The coding tool comprises an adaptive loop filter (ALF) tool thatcomprises an ALF classification process and/or an ALF filtering process.The method also includes performing the conversion according to thefirst determination and the second determination.

In another example aspect, a method of video processing is disclosed.The method includes determining, for a conversion between a currentblock of a video and a bitstream representation of the video, that oneor more samples of the video outside the current block are unavailablefor a coding process of the conversion. The method also includesperforming, based on the determining, the conversion by using paddedsamples for the one or more samples of the video. The padded samples aregenerated by checking for availability of samples in an order.

In another example aspect, a method of video processing is disclosed.The method includes performing a conversion between a video comprisingvideo pictures comprising a video unit and a bitstream representation ofthe video. A first set of syntax elements is included in the bitstreamrepresentation to indicate whether samples across boundaries of thevideo unit are accessible in a filtering process applicable toboundaries of the video unit, and the first set of syntax elements areincluded in different levels.

In another example aspect, a method of video processing is disclosed.The method includes performing a conversion between video blocks of avideo picture and a bitstream representation thereof. Here, the videoblocks are processed using logical groupings of coding tree blocks andthe coding tree blocks are processed based on whether a bottom boundaryof a bottom coding tree block is outside a bottom boundary of the videopicture.

In another example aspect, another video processing method is disclosed.The method includes determining, based on a condition of a coding treeblock of a current video block, a usage status of virtual samples duringan in-loop filtering and performing a conversion between the video blockand a bitstream representation of the video block consistent with theusage status of virtual samples.

In yet another example aspect, another video processing method isdisclosed. The method includes determining, during a conversion betweena video picture that is logically grouped into one or more video slicesor video bricks, and a bitstream representation of the video picture, todisable a use of samples in another slice or brick in the adaptive loopfilter process and performing the conversion consistent with thedetermining.

In yet another example aspect, another video processing method isdisclosed. The method includes determining, during a conversion betweena current video block of a video picture and a bitstream representationof the current video block, that the current video block includessamples located at a boundary of a video unit of the video picture andperforming the conversion based on the determining, wherein theperforming the conversion includes generating virtual samples for anin-loop filtering process using a unified method that is same for allboundary types in the video picture.

In yet another example aspect, another method of video processing isdisclosed. The method includes determining to apply, during a conversionbetween a current video block of a video picture and a bitstreamrepresentation thereof, one of multiple adaptive loop filter (ALF)sample selection methods available for the video picture during theconversion and performing the conversion by applying the one of multipleALF sample selection methods.

In yet another example aspect, another method of video processing isdisclosed. The method includes performing, based on a boundary rule, anin-loop filtering operation over samples of a current video block of avideo picture during a conversion between the current video block and abitstream representation of a current video block; wherein the boundaryrule disables using samples that cross a virtual pipeline data unit(VPDU) of the video picture and performing the conversion using a resultof the in-loop filtering operation.

In yet another example aspect, another method of video processing isdisclosed. The method includes performing, based on a boundary rule, anin-loop filtering operation over samples of a current video block of avideo picture during a conversion between the current video block and abitstream representation of a current video block; wherein the boundaryrule specifies to use, for locations of the current video block across avideo unit boundary, samples that are generated without using paddingand performing the conversion using a result of the in-loop filteringoperation.

In yet another example aspect, another method of video processing isdisclosed. The method includes performing, based on a boundary rule, anin-loop filtering operation over samples of a current video block of avideo picture during a conversion between the current video block and abitstream representation of a current video block; wherein the boundaryrule specifies selecting, for the in-loop filtering operation, a filterhaving dimensions such that samples of current video block used duringthe in-loop filtering do not cross a boundary of a video unit of thevideo picture and performing the conversion using a result of thein-loop filtering operation.

In yet another example aspect, another method of video processing isdisclosed. The method includes performing, based on a boundary rule, anin-loop filtering operation over samples of a current video block of avideo picture during a conversion between the current video block and abitstream representation of a current video block; wherein the boundaryrule specifies selecting, for the in-loop filtering operation, clippingparameters or filter coefficients based on whether or not padded samplesare needed for the in-loop filtering and performing the conversion usinga result of the in-loop filtering operation.

In yet another example aspect, another method of video processing isdisclosed. The method includes performing, based on a boundary rule, anin-loop filtering operation over samples of a current video block of avideo picture during a conversion between the current video block and abitstream representation of a current video block; wherein the boundaryrule depends on a color component identity of the current video blockand performing the conversion using a result of the in-loop filteringoperation.

In yet another example aspect, a video encoding apparatus configured toperform an above-described method is disclosed.

In yet another example aspect, a video decoder that is configured toperform an above-described method is disclosed.

In yet another example aspect, a machine-readable medium is disclosed.The medium stores code which, upon execution, causes a processor toimplement one or more of the above-described methods.

The above and other aspects and features of the disclosed technology aredescribed in greater detail in the drawings, the description and theclaims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows an example of a picture with 18 by 12 luma coding treeunits CTUs that is partitioned into 12 tiles and 3 raster-scan slices.

FIG. 2 shows an example of a picture with 18 by 12 luma CTUs that ispartitioned into 24 tiles and 9 rectangular slices.

FIG. 3 shows an example of a picture that is partitioned into 4 tiles,11 bricks, and 4 rectangular slices.

FIG. 4A shows an example of coding tree blocks CTBs crossing pictureborders when K=M, L<N.

FIG. 4B shows an example of coding tree blocks CTBs crossing pictureborders when K<M, L=N.

FIG. 4C shows an example of coding tree blocks CTBs crossing pictureborders when K<M, L<N.

FIG. 5 shows an example of encoder block diagram.

FIG. 6 is an illustration of picture samples and horizontal and verticalblock boundaries on the 8×8 grid, and the nonoverlapping blocks of the8×8 samples, which can be deblocked in parallel.

FIG. 7 shows examples of pixels involved in filter on/off decision andstrong/weak filter selection.

FIG. 8 shows four 1-D directional patterns.

FIG. 9 shows examples of geometric adaptive loop filtering (GALF) filtershapes (left: 5×5 diamond, middle: 7×7 diamond, right: 9×9 diamond).

FIG. 10 shows relative coordinates for the 5×5 diamond filter support.

FIG. 11 shows examples of relative coordinates for the 5×5 diamondfilter support.

FIG. 12A shows an example arrangement for sub sampled Laplaciancalculations.

FIG. 12B shows another example arrangement for sub sampled Laplaciancalculations.

FIG. 12C shows another example arrangement for sub sampled Laplaciancalculations.

FIG. 12D shows yet another example arrangement for sub sampled Laplaciancalculations.

FIG. 13 shows an example of a loop filter line buffer requirement inVTM-4.0 for Luma component.

FIG. 14 shows an example of a loop filter line buffer requirement inVTM-4.0 for Chroma component.

FIG. 15A shows an example of ALF block classification at virtualboundary when N=4.

FIG. 15B shows another example of ALF block classification at virtualboundary when N=4.

FIG. 16A illustrate an example of modified luma ALF filtering at virtualboundary.

FIG. 16B illustrate another example of modified luma ALF filtering atvirtual boundary.

FIG. 16C illustrate yet another example of modified luma ALF filteringat virtual boundary.

FIG. 17A shows an example of modified chroma ALF filtering at virtualboundary.

FIG. 17B shows another example of modified chroma ALF filtering atvirtual boundary.

FIG. 18A shows an example of horizontal wrap around motion compensation.

FIG. 18B shows another example of horizontal wrap around motioncompensation.

FIG. 19 illustrates an example of a modified adaptive loop filter.

FIG. 20 shows example of processing CTUs in a video picture.

FIG. 21 shows an example of a modified adaptive loop filter boundary.

FIG. 22 is a block diagram of an example of a video processingapparatus.

FIG. 23 is a flowchart for an example method of video processing.

FIG. 24 shows an example of an image of HEC in 3×2 layout.

FIG. 25 shows an example of number of padded lines for samples of twokinds of boundaries.

FIG. 26 shows an example of processing of CTUs in a picture.

FIG. 27 shows another example of processing of CTUs in a picture.

FIG. 28 shows another example of current sample and samples to berequired to be accessed.

FIG. 29 shows another example of padding of “unavailable” neighboringsamples.

FIG. 30 shows an example of samples need to be utilized in ALFclassification process.

FIG. 31 is a block diagram of an example video processing system inwhich disclosed techniques may be implemented.

FIG. 32 is a flowchart representation of a method for video processingin accordance with the present technology.

FIG. 33 is a flowchart representation of another method for videoprocessing in accordance with the present technology.

FIG. 34 is a block diagram that illustrates an example video codingsystem.

FIG. 35 is a block diagram that illustrates an encoder in accordancewith some embodiments of the present disclosure.

FIG. 36 is a block diagram that illustrates a decoder in accordance withsome embodiments of the present disclosure.

DETAILED DESCRIPTION

Section headings are used in the present document to facilitate ease ofunderstanding and do not limit the embodiments disclosed in a section toonly that section. Furthermore, while certain embodiments are describedwith reference to Versatile Video Coding or other specific video codecs,the disclosed techniques are applicable to other video codingtechnologies also. Furthermore, while some embodiments describe videocoding steps in detail, it will be understood that corresponding stepsdecoding that undo the coding will be implemented by a decoder.Furthermore, the term video processing encompasses video coding orcompression, video decoding or decompression and video transcoding inwhich video pixels are represented from one compressed format intoanother compressed format or at a different compressed bitrate.

1. BRIEF SUMMARY

This document is related to video coding technologies. Specifically, itis related to picture/slice/tile/brick boundary and virtual boundarycoding especially for the non-linear adaptive loop filter. It may beapplied to the existing video coding standard like HEVC, or the standard(Versatile Video Coding) to be finalized. It may be also applicable tofuture video coding standards or video codec.

2. INITIAL DISCUSSION

Video coding standards have evolved primarily through the development ofthe well-known ITU-T and ISO/IEC standards. The ITU-T produced H.261 andH.263, ISO/IEC produced MPEG-1 and MPEG-4 Visual, and the twoorganizations jointly produced the H.262/MPEG-2 Video and H.264/MPEG-4Advanced Video Coding (AVC) and H.265/HEVC standards. Since H.262, thevideo coding standards are based on the hybrid video coding structurewherein temporal prediction plus transform coding are utilized. Toexplore the future video coding technologies beyond HEVC, Joint VideoExploration Team (JVET) was founded by VCEG and MPEG jointly in 2015.Since then, many new methods have been adopted by JVET and put into thereference software named Joint Exploration Model (JEM). In April 2018,the JVET between VCEG (Q6/16) and ISO/IEC JTC1 SC29/WG11 (MPEG) wascreated to work on the VVC standard targeting at 50% bitrate reductioncompared to HEVC.

2.1 Color Space and Chroma Subsampling

Color space, also known as the color model (or color system), is anabstract mathematical model which simply describes the range of colorsas tuples of numbers, typically as 3 or 4 values or color components(e.g. RGB). Basically speaking, color space is an elaboration of thecoordinate system and sub-space.

For video compression, the most frequently used color spaces are YCbCrand RGB.

YCbCr, Y′CbCr, or Y Pb/Cb Pr/Cr, also written as YCBCR or Y′CBCR, is afamily of color spaces used as a part of the color image pipeline invideo and digital photography systems. Y′ is the luma component and CBand CR are the blue-difference and red-difference chroma components. Y′(with prime) is distinguished from Y, which is luminance, meaning thatlight intensity is nonlinearly encoded based on gamma corrected RGBprimaries.

Chroma sub sampling is the practice of encoding images by implementingless resolution for chromainformation than for luma information, takingadvantage of the human visual system's lower acuity for colordifferences than for luminance.

2.1.1 Color Format 4:4:4

Each of the three Y′CbCr components have the same sample rate, thusthere is no chroma sub sampling. This scheme is sometimes used inhigh-end film scanners and cinematic post production.

2.1.2 Color Format 4:2:2

The two chroma components are sampled at half the sample rate of luma:the horizontal chroma resolution is halved. This reduces the bandwidthof an uncompressed video signal by one-third with little to no visualdifference

2.1.3 Color Format 4:2:0

In 4:2:0, the horizontal sampling is doubled compared to 4:1:1, but asthe Cb and Cr channels are only sampled on each alternate line in thisscheme, the vertical resolution is halved. The data rate is thus thesame. Cb and Cr are each sub sampled at a factor of 2 both horizontallyand vertically. There are three variants of 4:2:0 schemes, havingdifferent horizontal and vertical siting.

In MPEG-2, Cb and Cr are cosited horizontally. Cb and Cr are sitedbetween pixels in the vertical direction (sited interstitially).

In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are sited interstitially,halfway between alternate luma samples.

In 4:2:0 DV. Cb and Cr are co-sited in the horizontal on In the verticaldirection, they are co-sited on alternating lines.

2.2 Various Video Units

A picture is divided into one or more tile rows and one or more tilecolumns. A tile is a sequence of CTUs that covers a rectangular regionof a picture.

A tile is divided into one or more bricks, each of which consisting of anumber of CTU rows within the tile.

A tile that is not partitioned into multiple bricks is also referred toas a brick. However, a brick that is a true subset of a tile is notreferred to as a tile.

A slice either contains a number of tiles of a picture or a number ofbricks of a tile.

Two modes of slices are supported, namely the raster-scan slice mode andthe rectangular slice mode. In the raster-scan slice mode, a slicecontains a sequence of tiles in a tile raster scan of a picture. In therectangular slice mode, a slice contains a number of bricks of a picturethat collectively form a rectangular region of the picture. The brickswithin a rectangular slice are in the order of brick raster scan of theslice.

FIG. 1 shows an example of raster-scan slice partitioning of a picture,where the picture is divided into 12 tiles and 3 raster-scan slices.

FIG. 2 shows an example of rectangular slice partitioning of a picture,where the picture is divided into 24 tiles (6 tile columns and 4 tilerows) and 9 rectangular slices.

FIG. 3 shows an example of a picture partitioned into tiles, bricks, andrectangular slices, where the picture is divided into 4 tiles (2 tilecolumns and 2 tile rows), 11 bricks (the top-left tile contains 1 brick,the top-right tile contains 5 bricks, the bottom-left tile contains 2bricks, and the bottom-right tile contain 3 bricks), and 4 rectangularslices.

2.2.1 CTU/CTB Sizes

In VVC, the CTU size, signaled in SPS by the syntax element log2_ctu_size_minus2, could be as small as 4×4.

7.3.2.3 Sequence Parameter Set RBSP Syntax

Descriptor seq_parameter_set_rbsp( ) {  sps_decoding_parameter_set_id u(4)  sps_video_parameter_set_id  u(4)  sps_max_sub_layers_minus1  u(3) sps_reserved_zero_5bits  u(5)  profile_tier_level(sps_max_sub_layers_minus1 )  gra_enabled_flag  u(1) sps_seq_parameter_set_id ue(v)  chroma_format_idc ue(v)  if(chroma_format_idc == 3 )   separate_colour_plane_flag  u(1) pic_width_in_luma_samples ue(v)  pic_height_in_luma_samples ue(v) conformance_window_flag  u(1)  if( conformance_window_flag ) {  conf_win_left_offset ue(v)   conf_win_tight_ offset ue(v)  conf_win_top_offset ue(v)   conf_win_bottom_offset ue(v)  } bit_depth_luma_minus8 ue(v)  bit_depth_chroma_minus8 ue(v) log2_max_pic_order_cnt_lsb_minus4 ue(v) sps_sub_layer_ordering_info_present_flag  u(1)  for( i = (sps_sub_layer_ordering_info_present_flag ? 0 : sps_max_sub_layers_minus1);    i <= sps_max_sub_layers_minus1; i++ ) {  sps_max_dec_pic_buffering_minus1[i] ue(v)  sps_max_num_reorder_pics[i] ue(v)   sps_max_latency_increase_plus1[i]ue(v)  }  long_term_ref_pics_flag  u(1)  sps_idr_rpl_present_flag  u(1) rpl1_same_as_rpl0_flag  u(1)  for( i = 0; i < !rpl1_same_as_rpl0_flag ?2 : 1; i++ ) {   num_ref_pic_lists_in_sps[i] ue(v)   for( j = 0; j <num_ref_pic_lists_in_sps[i]; j++)     ref_pic_list_struct(i,j )  } qtbtt_dual_tree_intra_flag  u(1)  log2_ctu_size_minus2 ue(v)  log2_min_luma_coding_ block_size_minus2 ue(v) partition_constraints_override_enabled_flag  u(1) sps_log2_diff_min_qt_min_cb_intra_slice_luma ue(v) sps_log2_diff_min_qt_min_cb_inter_slice ue(v) sps_max_mtt_hierarchy_depth_inter_slice ue(v) sps_max_mtt_hierarchy_depth_intra_slice_luma ue(v)  if(sps_max_mtt_hierarchy_depth_intra_slice_luma != 0 ) {  sps_log2_diff_max_bt_min_qt_intra_slice_luma ue(v)  sps_log2_diff_max_tt_min_qt_intra_slice_luma ue(v)  }  if(sps_max_mtt_hierarchy_depth_inter_slices != 0 ) {  sps_log2_diff_max_bt_min_qt_inter_slice ue(v)  sps_log2_diff_max_tt_min_qt_inter_slice ue(v)  }  if(qtbtt_dual_tree_intra_flag ) {   sps_log2_diff_min_qt_min_cb_intra_slicechroma ue(v)   sps_max_mtt_hierarchy_depth_intra_slice_chroma ue(v)   if( sps_max_mtt_hierarchy_depth_intra_slice_chroma != 0 ) {    sps_log2_diff_max_bt_min_qt_intra_slice_chroma ue(v)    sps_log2_diff_max_tt_min_qt_intra_slice_chroma ue(v)   }  } ... rbsp_trailing_bits( ) }log 2_ctu_size_minus2 plus 2 specifies the luma coding tree block sizeof each CTU.log 2_min_luma_coding_block_size_minus2 plus 2 specifies the minimumluma coding block size.The variables CtbLog2SizeY, CtbSizeY, MinCbLog2SizeY, MinCbSizeY,MinTbLog2SizeY, MaxTbLog2SizeY, MinTbSizeY, MaxTbSizeY, PicWidthInCtbsY,PicHeightlnCtbsY, PicSizeInCtbsY, PicWidthInMinCbsY, PicHeightlnMinCbsY,PicSizeInMinCbsY, PicSizelnSamplesY, PicWidthInSamplesC andPicHeightlnSamplesC are derived as follows:

$\begin{matrix}{{{Ctb}{Log}2{SizeY}} = {{\log 2{\_ ctu}{\_ size}{\_ minus2}} + 2}} & \left( {7 - 9} \right)\end{matrix}$ $\begin{matrix}{{CtbSizeY} = {1{{{Ctb}{Log}2{SizeY}}}}} & \left( {7 - 10} \right)\end{matrix}$ $\begin{matrix}{{{Min}{Cb}{Log}2{SizeY}} = {{\log 2{\_ min}{\_ luma}{\_ coding}{\_ block}{\_ size}{\_ minus}2} + 2}} & \left( {7 - 11} \right)\end{matrix}$ $\begin{matrix}{{MinCbSizeY} = {1{{{Min}{Cb}{Log}2{SizeY}}}}} & \left( {7 - 12} \right)\end{matrix}$ $\begin{matrix}{{{Min}{Tb}{Log}2{SizeY}} = 2} & \left( {7 - 13} \right)\end{matrix}$ $\begin{matrix}{{{Max}{Tb}{Log}2{SizeY}} = 6} & \left( {7 - 14} \right)\end{matrix}$ $\begin{matrix}{{MinTbSizeY} = {1{{{MinTbLog}2{SizeY}}}}} & \left( {7 - 15} \right)\end{matrix}$ $\begin{matrix}{{MaxTbSizeY} = {1{{{Max}{TbLog}2{SizeY}}}}} & \left( {7 - 16} \right)\end{matrix}$ $\begin{matrix}{{PicWidthInCtbsY} = {{Ceil}\left( {{pic\_ width}{\_ in}{\_ luma}{{\_ samples} \div {CtbSizeY}}} \right)}} & \left( {7 - 17} \right)\end{matrix}$ $\begin{matrix}{{PicHeightInCtbsY} = {{Ceil}\left( {{pic\_ height}{\_ in}{\_ luma}{{\_ samples} \div {CtbSizeY}}} \right)}} & \left( {7 - 18} \right)\end{matrix}$ $\begin{matrix}{{PicSizeInCtbsY} = {{PicWidthInCtbsY}*{PicHeightInCtbsY}}} & \left( {7 - 19} \right)\end{matrix}$ $\begin{matrix}{{{PicWidthIn}{MinCbsY}} = {{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{MinCbSizeY}}} & \left( {7 - 20} \right)\end{matrix}$ $\begin{matrix}{{PicHeightInMinCbsY} = {{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{MinCbSizeY}}} & \left( {7 - 21} \right)\end{matrix}$ $\begin{matrix}{{PicSizeInMinCbsY} = {{PicWidthInMinCbsY}*{PicHeightInMinCbsY}}} & \left( {7 - 22} \right)\end{matrix}$ $\begin{matrix}{{PicSizeInSamplesY} = {{pic\_ width}{\_ in}{\_ luma}{\_ samples}*{pic\_ height}{\_ in}{\_ luma}{\_ samples}}} & \left( {7 - 23} \right)\end{matrix}$ $\begin{matrix}{{PicWidthInSamplesC} = {{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{SubWidthC}}} & \left( {7 - 24} \right)\end{matrix}$ $\begin{matrix}{{PicHeightInSamplesC} = {{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{SubHeightC}}} & \left( {7 - 25} \right)\end{matrix}$

2.2.2 CTUs in a Picture

Suppose the CTB/LCU size indicated by M×N (typically M is equal to N, asdefined in HEVC/VVC), and for a CTB located at picture (or tile or sliceor other kinds of types, picture border is taken as an example) border,K×L samples are within picture border wherein either K<M or L<N. Forthose CTBs as depicted in FIG. 4A-4C, the CTB size is still equal toM×N, however, the bottom boundary/right boundary of the CTB is outsidethe picture.

FIG. 4A shows CTBs crossing the bottom picture border. FIG. 4B showsCTBs crossing the right picture border. FIG. 4C shows CTBs crossing theright bottom picture border

FIGS. 4A-4C show examples of CTBs crossing picture borders, (a) K=M,L<N; (b) K<M, L=N; (c) K<M, L<N

2.3 Coding Flow of a Typical Video Codec

FIG. 5 shows an example of encoder block diagram of VVC, which containsthree in-loop filtering blocks: deblocking filter (DF), sample adaptiveoffset (SAO) and ALF. Unlike DF, which uses predefined filters, SAO andALF utilize the original samples of the current picture to reduce themean square errors between the original samples and the reconstructedsamples by adding an offset and by applying a finite impulse response(FIR) filter, respectively, with coded side information signaling theoffsets and filter coefficients. ALF is located at the last processingstage of each picture and can be regarded as a tool trying to catch andfix artifacts created by the previous stages.

2.4 Deblocking Filter (DB)

The input of DB is the reconstructed samples before in-loop filters.

The vertical edges in a picture are filtered first. Then the horizontaledges in a picture are filtered with samples modified by the verticaledge filtering process as input. The vertical and horizontal edges inthe CTBs of each CTU are processed separately on a coding unit basis.The vertical edges of the coding blocks in a coding unit are filteredstarting with the edge on the left-hand side of the coding blocksproceeding through the edges towards the right-hand side of the codingblocks in their geometrical order. The horizontal edges of the codingblocks in a coding unit are filtered starting with the edge on the topof the coding blocks proceeding through the edges towards the bottom ofthe coding blocks in their geometrical order.

FIG. 6 is an illustration of picture samples and horizontal and verticalblock boundaries on the 8×8 grid, and the nonoverlapping blocks of the8×8 samples, which can be deblocked in parallel.

2.4.1. Boundary Decision

Filtering is applied to 8×8 block boundaries. In addition, it must be atransform block boundary or a coding subblock boundary (e.g., due tousage of Affine motion prediction, ATMVP). For those which are not suchboundaries, filter is disabled.

2.4.1 Boundary Strength Calculation

For a transform block boundary/coding subblock boundary, if it islocated in the 8×8 grid, it may be filtered and the setting ofbS[xD_(i)][yD_(j)] (wherein [xD_(i)][yD_(j)] denotes the coordinate) forthis edge is defined in Table 1 and Table 2, respectively.

TABLE 1 Boundary strength (when SPS IBC is disabled) Priority ConditionsY U V 5 At least one of the adjacent blocks is intra 2 2 2 4 TU boundaryand at least one of the adjacent 1 1 1 blocks has non-zero transformcoefficients 3 Reference pictures or number of MVs (1 for 1 N/A N/Auni-prediction, 2 for bi-prediction) of the adjacent blocks aredifferent 2 Absolute difference between the motion 1 N/A N/A vectors ofsame reference picture that belong to the adjacent blocks is greaterthan or equal to one integer luma sample 1 Otherwise 0 0 0

TABLE 2 Boundary strength (when SPS IBC is enabled) Priority ConditionsY U V 8 At least one of the adjacent blocks is intra 2 2 2 7 TU boundaryand at least one of the adjacent blocks has non-zero transformcoefficients 1 1 1 6 Prediction mode of adjacent blocks is 1 different(e.g., one is IBC, one is inter) 5 Both IBC and absolute differencebetween 1 N/A N/A the motion vectors that belong to the adjacent blocksis greater than or equal to one integer luma sample 4 Reference picturesor number of MVs (1 for 1 N/A N/A uni-prediction, 2 for bi-prediction)of the adjacent blocks are different 3 Absolute difference between themotion 1 N/A N/A vectors of same reference picture that belong to theadjacent blocks is greater than or equal to one integer luma sample 1Otherwise 0 0 0

2.4.3 Deblocking Decision for Luma Component

The deblocking decision process is described in this sub-section.

FIG. 7 shows examples of pixels involved in filter on/off decision andstrong/weak filter selection.

Wider-stronger luma filter is filters are used only if all theCondition1, Condition2 and Condition 3 are TRUE.

The condition 1 is the “large block condition”. This condition detectswhether the samples at P-side and Q-side belong to large blocks, whichare represented by the variable bSidePisLargeBlk and bSideQisLargeBlkrespectively. The bSidePisLargeBlk and bSideQisLargeBlk are defined asfollows.

bSidePisLargeBlk = ((edgetypeisverticalandp₀belongstoCUwithwidth >  = 32)❘❘(edgetypeishorizontalandp₀belongstoCUwithheight >  = 32))?TRUE : FALSEbSideQisLargeBlk = ((edgetypeisverticalandq₀belongstoCUwithwidth >  = 32)❘❘(edgetypeishorizontalandq₀belongstoCUwithheight >  = 32))?TRUE : FALSE

Based on bSidePisLargeBlk and bSideQisLargeBlk, the condition 1 isdefined as follows.

Condition1 = (bSidePisLargeBlkbSidePisLargeBlk)?TRUE : FALSE

Next, if Condition 1 is true, the condition 2 will be further checked.First, the following variables are derived:

-   -   dp0, dp3, dq0, dq3 are first derived as in HEVC    -   if (p side is greater than or equal to 32)

dp0 = (dp0 + Abs(p5₀ − 2 * p4₀ + p3₀) + 1)1dp3 = (dp3 + Abs(p5₃ − 2 * p4₃ + p3₃) + 1)1

-   -   if (q side is greater than or equal to 32)

dq0 = (dq0 + Abs(q5₀ − 2 * q4₀ + q3₀) + 1)1dq3 = (dq3 + Abs(q5₃ − 2 * q4₃ + q3₃) + 1)1Condition2 = (d < β)?TRUE : FALSE

where d=dp0+dq0+dp3+dq3.

If Condition 1 and Condition2 are valid, whether any of the blocks usessub-blocks is further checked:

  If (bSidePisLargeBlk)  {    If (mode block P == SUBBLOCKMODE)      Sp=5     else      Sp =7 } else  Sp = 3 If (bSideQisLargeBlk)   {    If(mode block Q == SUBBLOCKMODE)      Sq =5     else      Sq =7   } else Sq = 3

Finally, if both the Condition 1 and Condition 2 are valid, the proposeddeblocking method will check the condition 3 (the large block strongfilter condition), which is defined as follows.

In the Condition3 StrongFilterCondition, the following variables arederived:

  dpq is derived as in HEVC. sp₃ = Abs( p₃ − p₀ ), derived as in HEVC if(p side is greater than or equal to 32)   if(Sp==5)    sp₃ = ( sp₃ +Abs( p₅ − p₃ ) + 1 ) >> 1   else    sp₃ = ( sp₃ + Abs( p₇ − p₃ ) + 1) >> 1 sq₃ = Abs( q₀ − q₃ ), derived as in HEVC if (q side is greaterthan or equal to 32)  If(Sq==5)   sq₃ = ( sq₃ + Abs( q₅ − q₃ ) + 1 ) >>1  else   sq₃ = ( sq₃ + Abs( q₇ − q₃ ) + 1 ) >> 1

As in HEVC, StrongFilterCondition=(dpq is less than (β>>2), sp₃+sq₃ isless than (3*β>>5), and Abs(p₀−q₀) is less than (5*t_(C)+1)>>1) ? TRUE:FALSE.

2.4.4 Stronger Deblocking Filter for Luma (Designed for Larger Blocks)

Bilinear filter is used when samples at either one side of a boundarybelong to a large block. A sample belonging to a large block is definedas when the width >=32 for a vertical edge, and when height >=32 for ahorizontal edge.

The bilinear filter is listed below.

Block boundary samples p_(i) for i=0 to Sp−1 and q_(i) for j=0 to Sq−1(pi and qi are the i-th sample within a row for filtering vertical edge,or the i-th sample within a column for filtering horizontal edge) inHEVC deblocking described above) are then replaced by linearinterpolation as follows:

−p_(i)^(′) = (f_(i) * Middle_(s, t) + (64 − f_(i)) * P_(s) + 32)6), clippedtop_(i) ± tcPD_(i)−q_(j)^(′) = (ℊ_(j) * Middle_(s, t) + (64 − ℊ_(j)) * Q_(s) + 32)6), clippedtoq_(j) ± tcPD_(j)

where tcPD_(i) and tcPD_(j) term is a position dependent clippingdescribed in Section 2.4.7 and g_(j), f_(i), Middle_(s,t), P_(s) andQ_(s) are given below:

2.4.5 Deblocking Control for Chroma

The chroma strong filters are used on both sides of the block boundary.Here, the chroma filter is selected when both sides of the chroma edgeare greater than or equal to 8 (chroma position), and the followingdecision with three conditions are satisfied: the first one is fordecision of boundary strength as well as large block. The proposedfilter can be applied when the block width or height which orthogonallycrosses the block edge is equal to or larger than 8 in chroma sampledomain. The second and third one is basically the same as for HEVC lumadeblocking decision, which are on/off decision and strong filterdecision, respectively.

In the first decision, boundary strength (bS) is modified for chromafiltering and the conditions are checked sequentially. If a condition issatisfied, then the remaining conditions with lower priorities areskipped.

Chroma deblocking is performed when bS is equal to 2, orb S is equal to1 when a large block boundary is detected.

The second and third condition is basically the same as HEVC luma strongfilter decision as follows.

In the second condition:

-   -   d is then derived as in HEVC luma deblocking.

The second condition will be TRUE when d is less than (3.

In the third condition StrongFilterCondition is derived as follows:

-   -   dpq is derived as in HEVC.

sp₃ = Abs(p₃ − p₀), derivedasinHEVC sq₃ = Abs(q₀ − q₃), derivedasinHEVC

As in HEVC design, StrongFilterCondition=(dpq is less than (β>>2),sp₃+sq₃ is less than (β>>3), and Abs(p₀ q₀) is less than (5*t_(C)+1)>>1)

2.4.6 Strong Deblocking Filter for Chroma

The following strong deblocking filter for chroma is defined:

p₂^(′) = (3 * p₃ + 2 * p₂ + p₁ + p₀ + q₀ + 4)3p₁^(′) = (2 * p₃ + p₂ + 2 * p₁ + p₀ + q₀ + q₁ + 4)3p₀^(′) = (p₃ + p₂ + p₁ + 2 * p₀ + q₀ + q₁ + q₂ + 4)3

The proposed chroma filter performs deblocking on a 4×4 chroma samplegrid.

2.4.7 Position Dependent Clipping

The position dependent clipping tcPD is applied to the output samples ofthe luma filtering process involving strong and long filters that aremodifying 7, 5 and 3 samples at the boundary. Assuming quantizationerror distribution, it is proposed to increase clipping value forsamples which are expected to have higher quantization noise, thusexpected to have higher deviation of the reconstructed sample value fromthe true sample value.

For each P or Q boundary filtered with asymmetrical filter, depending onthe result of decision-making process in section 2.4.2, positiondependent threshold table is selected from two tables (e.g., Tc7 and Tc3tabulated below) that are provided to decoder as a side information:

Tc7 = {6, 5, 4, 3, 2, 1, 1}; Tc3 = {6, 4, 2};tcPD = (Sp =  = 3)?Tc3 : Tc7; tcQD = (Sq =  = 3)?Tc3 : Tc7;

For the P or Q boundaries being filtered with a short symmetricalfilter, position dependent threshold of lower magnitude is applied:

Tc3 = {3, 2, 1};

Following defining the threshold, filtered p′, and q′, sample values areclipped according to tcP and tcQ clipping values:

p_(i)^(″) = Clip3(p_(i)^(′) + tcP_(i), p_(i)^(′) − tcP_(i), p_(i)^(′));q_(j)^(″) = Clip3(q_(j)^(′) + tcQ_(j), q_(j)^(′) − tcQ_(j), q_(j)^(′));

where p′_(i) and q′_(i) are filtered sample values, p″_(i) and q″_(j)are output sample value after the clipping and tcP, tcP, are clippingthresholds that are derived from the VVC tc parameter and tcPD and tcQD.The function Clip3 is a clipping function as it is specified in VVC.

2.4.8 Sub-Block Deblocking Adjustment

To enable parallel friendly deblocking using both long filters andsub-block deblocking the long filters is restricted to modify at most 5samples on a side that uses sub-block deblocking (AFFINE or ATMVP orDMVR) as shown in the luma control for long filters. Additionally, thesub-block deblocking is adjusted such that that sub-block boundaries onan 8×8 grid that are close to a CU or an implicit TU boundary isrestricted to modify at most two samples on each side.

Following applies to sub-block boundaries that not are aligned with theCU boundary.

  If (mode block Q == SUBBLOCKMODE && edge !=0) {  if (!(implicitTU &&(edge == (64 /4))))   if (edge = 2 || edge == (orthogonalLength - 2) ||edge == (56 / 4) || edge == (72 / 4))    Sp = Sq = 2;   else    Sp = Sq= 3;  else   Sp = Sq = bSideQisLargeBlk ? 5:3 }

Where edge equal to 0 corresponds to CU boundary, edge equal to 2 orequal to orthogonalLength-2 corresponds to sub-block boundary 8 samplesfrom a CU boundary etc. Where implicit TU is true if implicit split ofTU is used.

2.5 SAO

The input of SAO is the reconstructed samples after DB. The concept ofSAO is to reduce mean sample distortion of a region by first classifyingthe region samples into multiple categories with a selected classifier,obtaining an offset for each category, and then adding the offset toeach sample of the category, where the classifier index and the offsetsof the region are coded in the bitstream. In HEVC and VVC, the region(the unit for SAO parameters signaling) is defined to be a CTU.

Two SAO types that can satisfy the requirements of low complexity areadopted in HEVC. Those two types are edge offset (EO) and band offset(BO), which are discussed in further detail below. An index of an SAOtype is coded (which is in the range of [0, 2]). For EO, the sampleclassification is based on comparison between current samples andneighboring samples according to 1-D directional patterns: horizontal,vertical, 135° diagonal, and 45° diagonal.

FIG. 8 shows four 1-D directional patterns for EO sample classification:horizontal (EO class=0), vertical (EO class=1), 135° diagonal (EOclass=2), and 45° diagonal (EO class=3)

For a given EO class, each sample inside the CTB is classified into oneof five categories. The current sample value, labeled as “c,” iscompared with its two neighbors along the selected 1-D pattern. Theclassification rules for each sample are summarized in Table I.Categories 1 and 4 are associated with a local valley and a local peakalong the selected 1-D pattern, respectively. Categories 2 and 3 areassociated with concave and convex corners along the selected 1-Dpattern, respectively. If the current sample does not belong to EOcategories 1-4, then it is category 0 and SAO is not applied.

TABLE 3 Sample Classification Rules for Edge Offset Category Condition 1c < a and c < b 2 ( c < a && c == b) || (c == a && c < b) 3 ( c > a && c== b) || (c == a && c > b) 4 c > a && c > b 5 None of above

2.6 Geometry Transformation-Based Adaptive Loop Filter

The input of DB is the reconstructed samples after DB and SAO. Thesample classification and filtering process are based on thereconstructed samples after DB and SAO.

In some embodiments, a geometry transformation-based adaptive loopfilter (GALF) with block-based filter adaption is applied. For the lumacomponent, one among 25 filters is selected for each 2×2 block, based onthe direction and activity of local gradients.

2.6.1 Filter Shape

In some embodiments, up to three diamond filter shapes (as shown in FIG.9 ) can be selected for the luma component. An index is signalled at thepicture level to indicate the filter shape used for the luma component.Each square represents a sample, and Ci (i being 0-6 (left), 0-12(middle), 0-20 (right)) denotes the coefficient to be applied to thesample. For chroma components in a picture, the 5×5 diamond shape isalways used.

2.6.1.1 Block Classification

Each 2×2 block is categorized into one out of 25 classes. Theclassification index C is derived based on its directionality D and aquantized value of activity A, as follows:

$\begin{matrix}{C = {{5D} + {\hat{A}.}}} & (1)\end{matrix}$

To calculate D and Â, gradients of the horizontal, vertical and twodiagonal direction are first calculated using 1-D Laplacian:

$\begin{matrix}{{{\mathcal{g}}_{v} = {\sum\limits_{k = {i - 2}}^{i + 3}{\sum\limits_{l = {j - 2}}^{j + 3}V_{k,l}}}},{V_{k,l} = {❘{{2{R\left( {k,l} \right)}} - {R\left( {k,{l - 1}} \right)} - {R\left( {k,{l + 1}} \right)}}❘}},} & (2)\end{matrix}$ $\begin{matrix}{{{\mathcal{g}}_{h} = {\sum\limits_{k = {i - 2}}^{i + 3}{\sum\limits_{l = {j - 2}}^{j + 3}H_{k,l}}}},{H_{k,l} = {❘{{2{R\left( {k,l} \right)}} - {R\left( {{k - 1},l} \right)} - {R\left( {{k + 1},l} \right)}}❘}},} & (3)\end{matrix}$ $\begin{matrix}{{{\mathcal{g}}_{d1} = {\sum\limits_{k = {i - 2}}^{i + 3}{\sum\limits_{l = {j - 3}}^{j + 3}{D1_{k,l}}}}},{{D1_{k,l}} = {❘{{2{R\left( {k,l} \right)}} - {R\left( {{k - 1},{l - 1}} \right)} - {R\left( {{k + 1},{l + 1}} \right)}}❘}}} & (4)\end{matrix}$ $\begin{matrix}{{{\mathcal{g}}_{d2} = {\sum\limits_{k = {i - 2}}^{i + 3}{\sum\limits_{j = {j - 2}}^{j + 3}{D2_{k,l}}}}},{{D2_{k,l}} = {❘{{2{R\left( {k,l} \right)}} - {R\left( {{k - 1},{l + 1}} \right)} - {R\left( {{k + 1},{l - 1}} \right)}}❘}}} & (5)\end{matrix}$

Indices i and j refer to the coordinates of the upper left sample in the2×2 block and R(i,j) indicates a reconstructed sample at coordinate(i,j).

Then D maximum and minimum values of the gradients of horizontal andvertical directions are set as:

$\begin{matrix}{{{\mathcal{g}}_{h,v}^{\max} = {\max\left( {{\mathcal{g}}_{h},{\mathcal{g}}_{v}} \right)}},{{\mathcal{g}}_{h,v}^{\min} = {\min\left( {{\mathcal{g}}_{h},{\mathcal{g}}_{v}} \right)}},} & (6)\end{matrix}$

and the maximum and minimum values of the gradient of two diagonaldirections are set as:

$\begin{matrix}{{{\mathcal{g}}_{{d0},{d1}}^{\max} = {\max\left( {{\mathcal{g}}_{d0},{\mathcal{g}}_{d1}} \right)}},{{\mathcal{g}}_{{d0},{d1}}^{\min} = {\min\left( {{\mathcal{g}}_{d0},{\mathcal{g}}_{d1}} \right)}},} & (7)\end{matrix}$

To derive the value of the directionality D, these values are comparedagainst each other and with two thresholds t₁ and t₂:

Step 1. If both g_(h,v) ^(max)≤t₁ g_(h,v) ^(min) and g_(d0,d1)^(max)≤g_(d0,d1) ^(min) are true, D is set to 0.

Step 2. If g_(h,v) ^(max)/g_(h,v) ^(min)>g_(d0,d1) ^(max)/g_(d0,d1)^(min), continue from Step 3; otherwise continue from Step 4.

Step 3. If g_(h,v) ^(max)>t₂·g_(h,v) ^(min), D is set to 2; otherwise Dis set to 1.

Step 4. If g_(d0,d1) ^(max)>t₂ g_(d0,d1) ^(min), D is set to 4;otherwise D is set to 3.

The activity value A is calculated as:

$\begin{matrix}{A = {\sum\limits_{k = {i - 2}}^{i + 3}{\sum\limits_{l = {j - 2}}^{j + 3}{\left( {V_{k,l} + H_{k,l}} \right).}}}} & (8)\end{matrix}$

A is further quantized to the range of 0 to 4, inclusively, and thequantized value is denoted as Â.

For both chroma components in a picture, no classification method isapplied, e.g a single set of ALF coefficients is applied for each chromacomponent.

2.6.1.2 Geometric Transformations of Filter Coefficients

FIG. 10 shows relative coordinator for the 5×5 diamond filter support:Left: Diagonal Center: Vertical flip, Right: Rotation.

Before filtering each 2×2 block, geometric transformations such asrotation or diagonal and vertical flipping are applied to the filtercoefficients f (k,l), which is associated with the coordinate (k,l),depending on gradient values calculated for that block. This isequivalent to applying these transformations to the samples in thefilter support region. The idea is to make different blocks to which ALFis applied more similar by aligning their directionality.

Three geometric transformations, including diagonal, vertical flip androtation are introduced:

$\begin{matrix}{{{{Diagonal}:{f_{D}\left( {k,l} \right)}} = {f\left( {l,k} \right)}},} & (9)\end{matrix}$ Verticalflip : f_(V)(k, l) = f(k, K − l − 1),Rotation : f_(R)(k, l) = f(K − l − 1, k).

where K is the size of the filter and 0≤k,l≤K−1 are coefficientscoordinates, such that location (0,0) is at the upper left corner andlocation (K−1, K−1) is at the lower right corner. The transformationsare applied to the filter coefficients f (k,l) depending on gradientvalues calculated for that block. The relationship between thetransformation and the four gradients of the four directions aresummarized in Table 4. FIG. 9 shows the transformed coefficients foreach position based on the 5×5 diamond.

TABLE 4 Mapping of the gradient calculated for one block and thetransformations Gradient values Transformation g_(d2) < g_(d1) and g_(h)< g_(v) No transformation g_(d2) < g_(d1) and g_(v) < g_(h) Diagonalg_(d1) < g_(d2) and g_(h) < g_(v) Vertical flip g_(d1) < g_(d2) andg_(v) < g_(h) Rotation

2.6.1.3 Filter Parameters Signalling

In some embodiments, GALF filter parameters are signalled for the firstCTU, e.g., after the slice header and before the SAO parameters of thefirst CTU. Up to 25 sets of luma filter coefficients could be signalled.To reduce bits overhead, filter coefficients of different classificationcan be merged. Also, the GALF coefficients of reference pictures arestored and allowed to be reused as GALF coefficients of a currentpicture. The current picture may choose to use GALF coefficients storedfor the reference pictures and bypass the GALF coefficients signalling.In this case, only an index to one of the reference pictures issignalled, and the stored GALF coefficients of the indicated referencepicture are inherited for the current picture.

To support GALF temporal prediction, a candidate list of GALF filtersets is maintained. At the beginning of decoding a new sequence, thecandidate list is empty. After decoding one picture, the correspondingset of filters may be added to the candidate list. Once the size of thecandidate list reaches the maximum allowed value (e.g., 6), a new set offilters overwrites the oldest set in decoding order, and that is,first-in-first-out (FIFO) rule is applied to update the candidate list.To avoid duplications, a set could only be added to the list when thecorresponding picture doesn't use GALF temporal prediction. To supporttemporal scalability, there are multiple candidate lists of filter sets,and each candidate list is associated with a temporal layer. Morespecifically, each array assigned by temporal layer index (TempIdx) maycompose filter sets of previously decoded pictures with equal to lowerTempIdx. For example, the k-th array is assigned to be associated withTempIdx equal to k, and it only contains filter sets from pictures withTempIdx smaller than or equal to k. After coding a certain picture, thefilter sets associated with the picture will be used to update thosearrays associated with equal or higher TempIdx.

Temporal prediction of GALF coefficients is used for inter coded framesto minimize signalling overhead. For intra frames, temporal predictionis not available, and a set of 16 fixed filters is assigned to eachclass. To indicate the usage of the fixed filter, a flag for each classis signalled and if required, the index of the chosen fixed filter. Evenwhen the fixed filter is selected for a given class, the coefficients ofthe adaptive filter f (k, 1) can still be sent for this class in whichcase the coefficients of the filter which will be applied to thereconstructed image are sum of both sets of coefficients.

The filtering process of luma component can controlled at CU level. Aflag is signalled to indicate whether GALF is applied to the lumacomponent of a CU. For chroma component, whether GALF is applied or notis indicated at picture level only.

2.6.1.4 Filtering Process

At decoder side, when GALF is enabled for a block, each sample R(i,j)within the block is filtered, resulting in sample value R′(i,j) as shownbelow, where L denotes filter length, f_(m,n) represents filtercoefficient, and f (k,l) denotes the decoded filter coefficients.

$\begin{matrix}{{R^{\prime}\left( {i,j} \right)} = {\sum_{k = {- L/2}}^{L/2}{\sum_{l = {- L/2}}^{L/2}{{f\left( {k,l} \right)} \times {R\left( {{i + k},{j + l}} \right)}}}}} & (10)\end{matrix}$

FIG. 11 shows an example of relative coordinates used for 5×5 diamondfilter support supposing the current sample's coordinate (i,j) to be (0,0). Samples in different coordinates filled with the same color aremultiplied with the same filter coefficients.

2.7 Geometry Transformation-Based Adaptive Loop Filter (GALF)

2.7.1 Example GALF

In some embodiments, the filtering process of the Adaptive Loop Filter,is performed as follows:

$\begin{matrix}{{{O\left( {x,y} \right)} = {\sum_{({i,j})}{{w\left( {i,j} \right)}.{I\left( {{x + i},{y + j}} \right)}}}},} & (11)\end{matrix}$

where samples l(x+i, y+j) are input samples, O(x,y) is the filteredoutput sample (e.g. filter result), and w(i,j) denotes the filtercoefficients. In practice, in VTM4.0 it is implemented using integerarithmetic for fixed point precision computations:

$\begin{matrix}{{{{{O\left( {x,y} \right)} = \left( {{\sum_{i = {- \frac{L}{2}}}^{\frac{L}{2}}{\sum_{j = {- \frac{L}{2}}}^{\frac{L}{2}}{{w\left( {i,j} \right)}.{I\left( {{x + i},{y + j}} \right)}}}} + 64} \right)}}7},} & (12)\end{matrix}$

where L denotes the filter length, and where w(i,j) are the filtercoefficients in fixed point precision.

The current design of GALF in VVC has the following major changes:

(1) The adaptive filter shape is removed. Only 7×7 filter shape isallowed for luma component and 5×5 filter shape is allowed for chromacomponent.

(2) Signaling of ALF parameters in removed from slice/picture level toCTU level.

(3) Calculation of class index is performed in 4×4 level instead of 2×2.In addition, in some embodiments, sub-sampled Laplacian calculationmethod for ALF classification is utilized. More specifically, there isno need to calculate the horizontal/vertical/45 diagonal/135 degreegradients for each sample within one block. Instead, 1:2 subsampling isutilized.

FIG. 12A-12D show Sub sampled Laplacian calculation for CE2.6.2. FIG. 12A illustrates sub sampled positions for vertical gradient, FIG. 12illustrates sub sampled positions for horizontal gradient, FIG. 12Cillustrates sub sampled positions for diagonal gradient, and FIG. 12Dillustrates sub sampled positions for diagonal gradient.

2.8 Non-Linear ALF

2.8.1 Filtering Reformulation

Equation (11) can be reformulated, without coding efficiency impact, inthe following expression:

$\begin{matrix}{{{O\left( {x,y} \right)} = {{I\left( {x,y} \right)} + {\sum_{{({i,j})} \neq {({0,0})}}{{w\left( {i,j} \right)}.\left( {{I\left( {{x + i},{y + j}} \right)} - {I\left( {x,y} \right)}} \right)}}}},} & (13)\end{matrix}$

where w(i,j) are the same filter coefficients as in equation (11)[excepted w(0, 0) which is equal to 1 in equation (13) while it is equalto 1−Σ_((i,j)≠(0,0)) w(i,j) in equation (11)].

Using this above filter formula of (13), VVC introduces thenon-linearity to make ALF more efficient by using a simple clippingfunction to reduce the impact of neighbor sample values (I (x+i, y+j))when they are too different with the current sample value (I(x,y)) beingfiltered.

More specifically, the ALF filter is modified as follows:

$\begin{matrix}{{{O^{\prime}\left( {x,y} \right)} = {{I\left( {x,y} \right)} + {\sum_{{({i,j})} \neq {({0,0})}}{{w\left( {i,j} \right)}.{K\left( {{{I\left( {{x + i},{y + j}} \right)} - {I\left( {x,y} \right)}},{k\left( {i,j} \right)}} \right)}}}}},} & (14)\end{matrix}$

where K(d,b)=min (b, max(−b, d)) is the clipping function, and k (i,j)are clipping parameters, which depends on the (i,j) filter coefficient.The encoder performs the optimization to find the best k (i,j).

In some embodiments, the clipping parameters k(i,j) are specified foreach ALF filter, one clipping value is signaled per filter coefficient.It means that up to 12 clipping values can be signalled in the bitstreamper Luma filter and up to 6 clipping values for the Chroma filter.

In order to limit the signaling cost and the encoder complexity, only 4fixed values which are the same for INTER and INTRA slices are used.

Because the variance of the local differences is often higher for Lumathan for Chroma, two different sets for the Luma and Chroma filters areapplied. The maximum sample value (here 1024 for 10 bits bit-depth) ineach set is also introduced, so that clipping can be disabled if it isnot necessary.

The sets of clipping values used in some embodiments are provided in theTable 5. The 4 values have been selected by roughly equally splitting,in the logarithmic domain, the full range of the sample values (coded on10 bits) for Luma, and the range from 4 to 1024 for Chroma.

More precisely, the Luma table of clipping values have been obtained bythe following formula:

$\begin{matrix}{\left. \left. {{AlfClip}_{L} = \left\{ {{{round}\left( \left( (M)^{\frac{1}{N}} \right)^{N - n + 1} \right){for}n} \in {1\ldots N}} \right.} \right\rbrack \right\},{{{with}M} = {{2^{10}{and}N} = 4.}}} & (15)\end{matrix}$

Similarly, the Chroma tables of clipping values is obtained according tothe following formula:

$\begin{matrix}{\left. \left. {{AlfClip}_{C} = \left\{ {{{{round}\left( {A.\left( \left( \frac{M}{A} \right)^{\frac{1}{N - 1}} \right)^{N - n}} \right)}{for}n} \in {1\ldots N}} \right.} \right\rbrack \right\},{{{with}M} = 2^{10}},{N = {{4{and}A} = 4.}}} & (16)\end{matrix}$

TABLE 5 Authorized clipping values INTRA/INTER tile group LUMA {1024,181, 32, 6} CHROMA {1024, 161, 25, 4}

The selected clipping values are coded in the “alf_data” syntax elementby using a Golomb encoding scheme corresponding to the index of theclipping value in the above Table 5. This encoding scheme is the same asthe encoding scheme for the filter index.

2.9 Virtual Boundary

In hardware and embedded software, picture-based processing ispractically unacceptable due to its high picture buffer requirement.Using on-chip picture buffers is very expensive and using off-chippicture buffers significantly increases external memory access, powerconsumption, and data access latency. Therefore, DF, SAO, and ALF willbe changed from picture-based to LCU-based decoding in real products.When LCU-based processing is used for DF, SAO, and ALF, the entiredecoding process can be done LCU by LCU in a raster scan with anLCU-pipelining fashion for parallel processing of multiple LCUs. In thiscase, line buffers are required for DF, SAO, and ALF because processingone LCU row requires pixels from the above LCU row. If off-chip linebuffers (e.g. DRAM) are used, the external memory bandwidth and powerconsumption will be increased; if on-chip line buffers (e.g. SRAM) areused, the chip area will be increased. Therefore, although line buffersare already much smaller than picture buffers, it is still desirable toreduce line buffers.

In some embodiments, as shown in FIG. 13 , the total number of linebuffers required is 11.25 lines for the Luma component. The explanationof the line buffer requirement is as follows: The deblocking ofhorizontal edge overlapping with CTU edge cannot be performed as thedecisions and filtering require lines K, L, M, M from the first CTU andLines O, P from the bottom CTU. Therefore, the deblocking of thehorizontal edges overlapping with the CTU boundary is postponed untilthe lower CTU comes. Therefore for the lines K, L, M, N reconstructedluma samples have to be stored in the line buffer (4 lines). Then theSAO filtering can be performed for lines A till J. The line J can be SAOfiltered as deblocking does not change the samples in line K. For SAOfiltering of line K, the edge offset classification decision is onlystored in the line buffer (which is 0.25 Luma lines). The ALF filteringcan only be performed for lines A-F. As shown in FIG. 13 , the ALFclassification is performed for each 4×4 block. Each 4×4 blockclassification needs an activity window of size 8×8 which in turn needsa 9×9 window to compute the 1d Laplacian to determine the gradient.

Therefore, for the block classification of the 4×4 block overlappingwith lines G, H, J needs, SAO filtered samples below the Virtualboundary. In addition, the SAO filtered samples of lines D, E, F arerequired for ALF classification. Moreover, the ALF filtering of Line Gneeds three SAO filtered lines D, E, F from above lines. Therefore, thetotal line buffer requirement is as follows:

-   -   Lines K-N(Horizontal DF pixels): 4 lines    -   Lines D-J (SAO filtered pixels): 7 lines    -   SAO Edge offset classifier values between line J and line K:        0.25 line

Therefore, the total number of luma lines required is 7+4+0.25=11.25.

Similarly, the line buffer requirement of the Chroma component isillustrated in FIG. 14 . The line buffer requirement for Chromacomponent is evaluated to be 6.25 lines.

In order to eliminate the line buffer requirements of SAO and ALF, theconcept of virtual boundary (VB) is introduced in the latest VVC. Asshown in FIG. 13 , VBs are upward shifted horizontal LCU boundaries by Npixels. For each LCU, SAO and ALF can process pixels above the VB beforethe lower LCU comes but cannot process pixels below the VB until thelower LCU comes, which is caused by DF. With consideration of thehardware implementation cost, the space between the proposed VB and thehorizontal LCU boundary is set as four pixels for luma (e.g. N=4 in FIG.13 ) and two pixels for chroma (e.g. N=2 in FIG. 9 ).

2.9.1 Modified ALF Block Classification when VB Size N is 4

FIGS. 15A-15B depict modified block classification for the case when thevirtual boundary is 4 lines above the CTU boundary (N=4). As depicted inFIG. 15A, for the 4×4 block starting at line G, the block classificationonly uses the lines E till J. However Laplacian gradient calculation forthe samples belonging to line J requires one more line below (line K).Therefore, line K is padded with line J.

Similarly, as depicted in FIG. 15B, for the 4×4 block starting at lineK, the block classification only uses the lines K till P. HoweverLaplacian gradient calculation for the samples belonging to line Krequire one more line above (line J). Therefore, line J is padded withline K.

2.9.2 Two-Side Padding for Samples Cross Virtual Boundaries

As depicted in FIGS. 16A-16C, truncated version of the filters is usedfor filtering of the luma samples belonging to the lines close to thevirtual boundaries. Taking FIG. 16A for example, when filtering the lineM as denoted in FIG. 13 , e.g., the center sample of the 7×7 diamondsupport is in the line M. it requires to access one line above the VB(denoted by bold line). In this case, the samples above the VB is copiedfrom the right below sample below the VB, such as the P0 sample in thesolid line is copied to the above dash position. Symmetrically, P3sample in the solid line is also copied to the right below dashedposition even the sample for that position is available. The copiedsamples are only used in the luma filtering process.

The padding method used for ALF virtual boundaries may be denoted as‘Two-side Padding’ wherein if one sample located at (i,j) (e.g., the P0Awith dash line in FIG. 16B) is padded, then the corresponding samplelocated at (m,n) (e.g., the P3B with dash line in FIG. 16B) which sharethe same filter coefficient is also padded even the sample is available,as depicted in FIGS. 16A-16C and FIGS. 17A-17B. In FIGS. 16A-16C, 7×7diamond filter support, center is the current sample to be filtered.FIG. 16A shows one required line above/below VB need to be padded. FIG.16B shows 2 required lines above/below VB need to be padded. FIG. 16Cshows 3 required lines above/below VB need to be padded.

Similarly, as depicted in FIGS. 17A-17B, the two-side padding method isalso used for chroma ALF filtering. FIGS. 17A-17B show modified chromaALF filtering at virtual boundary (5×5 diamond filter support, center isthe current sample to be filtered). FIG. 17A shows 1 required linesabove/below VB need to be padded. FIG. 17B shows 2 required linesabove/below VB need to be padded.

2.9.3 Alternative Way for Implementation of the Two-Side Padding whenNon-Linear ALF is Disabled

When the non-linear ALF is disabled fora CTB, e.g., the clippingparameters k(i,j) in equation (14) are equal to (1<<Bitdepth), thepadding process could be replaced by modifying the filter coefficients(a.k.a modified-coeff based ALF, MALF). For example, when filteringsamples in line L/I, the filter coefficient c5 is modified to c5′, inthis case, there is no need to copy the luma samples from the solid P0Ato dashed P0A and solid P3B to dashed P3B FIG. 18A. In this case, thetwo-side padding and MALF will generate the same results, assuming thecurrent sample to be filtered is located at (x,y).

$\begin{matrix}{{{c5.{K\left( {{{I\left( {{x - 1},{y - 1}} \right)} - {I\left( {x,y} \right)}},{k\left( {{- 1},{- 1}} \right)}} \right)}} + {c1.{K\left( {{{I\left( {{x - 1},{y - 2}} \right)} - {I\left( {x,y} \right)}},{k\left( {{- 1},{- 2}} \right)}} \right)}}} = {\left( {{c5} + {c1}} \right).{K\left( {{{I\left( {{x - 1},{y - 1}} \right)} - {I\left( {x,y} \right)}},{k\left( {{- 1},{- 1}} \right)}} \right)}}} & (17)\end{matrix}$

since K(d,b)=d and l(x−1,y−1)=/(x−1,y−2) due to padding.

However, when the non-linear ALF is enabled, MALF and two-side paddingmay generate different filtered results, since the non-linear parametersare associated with each coefficient, such as for filter coefficients c5and c1, the clipping parameters are different Therefore,

$\begin{matrix}{{{c5.{K\left( {{{I\left( {{x - 1},{y - 1}} \right)} - {I\left( {x,y} \right)}},{k\left( {{- 1},{- 1}} \right)}} \right)}} + {c1.{K\left( {{{I\left( {{x - 1},{y - 2}} \right)} - {I\left( {x,y} \right)}},{k\left( {{- 1},{- 2}} \right)}} \right)}}}!={\left( {{c5} + {c1}} \right).{K\left( {{{I\left( {{x - 1},{y - 1}} \right)} - {I\left( {x,y} \right)}},{k\left( {{- 1},{- 1}} \right)}} \right)}}} & (18)\end{matrix}$

since K(d,b) !=d, even l(x−1, y−1)=/(x−1,y−2) due to padding.

2.10 Specification on ALF Filtering

Newly added parts are indicated in bold italicized underlined text. Thedeleted parts are indicated using [[ ]].

7.3.2.4 Picture Parameter Set RBSP Syntax

Descriptor pic_parameter_set_rbsp( ) {  pps_pic_parameter_set_id ue(v) pps_seq_parameter_set_id ue(v)  output_flag_present_flag u(1) single_tile_in_pic_flag u(1)  if(!single_tile_in_pic_flag) {  uniform_tile_spacing_flag u(1)   if(uniform_tile_spacing_flag) {   tile_cols_width_minus1 ue(v)    tile_rows_height_minus1 ue(v)   }else {    num_tile_columns_minus1 ue(v)    num_tile_rows_minus1 ue(v)   for(i = 0; i < num_tile_columns_minus1; i++)     tile_columnwidth_minus1[i] ue(v)    for(i = 0; i < num_tile_rows_minus1; i++)    tile_row_height_minus1[i] ue(v)   }   brick_splitting_present_flagu(1)   for(i = 0; brick_splitting_present_flag && i < Num TiksInPic;i++) {    brick_split_flag[i] u(1)    if( brick_split_flag[i] ) {    uniform_brick_spacing_flag[i] u(1)    if(uniform_brick_spacing_flag[i] )      brick_height_minus1[i] ue(v)    else {      num_brick_rows_minus1[i] ue(v)      for(j = 0; j <num_brick_rows_minus1[i]; j++)       brick_row_height_minus1[i][j] ue(v)    }    }   }   single_blick_per_slice_flag u(1)  if(!single_brick_per_slice_flag)    rect_slice_flag u(1)  if(rect_slice_flag && !single_brick_per_slice_flag) {   num_slices_in_pic_minus1 ue(v)    for(i = 0; i <=num_slices_in_pic_minus1; i++) {     if(i > 0)     top_left_brick_idx[i] u(v)     bottom_right_brick_idx_delta[i] u(v)   }   }

   

 

 

  

   

 

   if(rect_slice_flag) {   signalled_slice_id_flag u(1)  if(signalled_slice_id_flag) {    signalled_slice_id_length_minus1ue(v)    for(i = 0;i <= num_slices_in_pic_minus1;i++)     slice_id[i]u(v)   }  }  entropy_coding_sync_enabled_flag u(1) cabac_init_present_flag u(1)  for(i = 0; i < 2; i++ )  num_ref_idx_default_active_minus1[i] ue(v)  rpl1_idx_present_flag u(1) init_qp_minus26 se(v)  transform_skip_enabled_flag u(1) if(transform_skip_enabled_flag)   log2_transform_skip_max_size_minus2ue(v)  cu_qp_delta_enabled_flag u(1)  if(cu_qp_delta_enabled_flag)  cu_qp_delta_subdiv ue(v)  pps_cb_qp_offset se(v)  pps_cr_qp_offsetse(v)  pps_joint_cbcr_qp_offset se(v) pps_slice_chroma_qp_offsets_present_flag u(1)  weighted_pred_flag u(1) weighted_bipred_flag u(1)  deblocking_filter_control_present_flag u(1) if(deblocking_filter_control_present_flag){  deblocking_filter_overnde_enabled_flag u(1)  pps_deblocking_filter_disabled_flag u(1)  if(!pps_deblocking_filter_disabled_flag){    pps_beta_offset_div2se(v)    pps_tc_offset_div2 se(v)   }  } pps_loop_filter_across_virtual_boundaries_disabled_flag u(1) if(pps_loop_filter_across_virtual_boundaries_disabled_flag) {  pps_num_ver_virtual_boundaries u(2)   for(i = 0; i <pps_num_ver_virtual_boundaries; i++)    pps_virtual_boundaries_pos_x[i]u(v)   pps_num_hor_virtual_boundaries u(2)   for(i = 0; i <pps_num_hor_virtual_boundaries; i++)    pps_virtual_boundaties_pos_y[i]u(v)  }  pps_extension_flag u(1)  if(pps_extension_flag)  while(more_rbsp_data( ) )    pps_extension_data_flag u(1) rbsp_trailing_bits( ) }loop_filter_across_bricks_enabled_flag equal to 1 specifies that in-loopfiltering operations may be performed across brick boundaries inpictures referring to the PPS. loop_filter_across_bricks_enabled_flagequal to 0 specifies that in-loop filtering operations are not performedacross brick boundaries in pictures referring to the PPS. The in-loopfiltering operations include the deblocking filter, sample adaptiveoffset filter, and adaptive loop filter operations. When not present,the value of loop_filter_across_bricks_enabled_flag is inferred to beequal to 1.loop_filter_across_slices_enabled_flag equal to 1 specifies that in-loopfiltering operations may be performed across slice boundaries inpictures referring to the PPS. loop_filter_across_slice_enabled_flagequal to 0 specifies that in-loop filtering operations are not performedacross slice boundaries in pictures referring to the PPS. The in-loopfiltering operations include the deblocking filter, sample adaptiveoffset filter, and adaptive loop filter operations. When not present,the value of loop_filter_across_slices_enabled_flag is inferred to beequal to 0.pps_loop_filter_across_virtual_boundaries_disabled_flag equal to 1specifies that the in-loop filtering operations are disabled across thevirtual boundaries in pictures referring to the PPS.pps_loop_filter_across_virtual_boundaries_disabled_flag equal to 0specifies that no such disabling of in-loop filtering operations isapplied in pictures referring to the PPS. The in-loop filteringoperations include the deblocking filter, sample adaptive offset filter,and adaptive loop filter operations. When not present, the value ofpps_loop_filter_across_virtual_boundaries_disabled_flag is inferred tobe equal to 0.pps_num_ver_sirtual_boundaries specifies the number ofpps_virtual_boundaries_pos_x[i] syntax elements that are present in thePPS. When pps_num_ver_virtual_boundaries is not present, it is inferredto be equal to 0.

8.8.5.2 Coding Tree Block Filtering Process for Luma Samples

Inputs of this process are:

-   -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process,    -   a filtered reconstructed luma picture sample array        alfPicture_(L),    -   a luma location (xCtb,yCtb) specifying the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        luma picture sample array alfPicture_(L).        The derivation process for filter index clause 8.8.5.3 is        invoked with the location (xCtb, yCtb) and the reconstructed        luma picture sample array recPicture_(L) as inputs, and        filtIdx[x][y] and transposeIdx[x][y] with x, y=0 . . .        CtbSizeY−1 as outputs.        For the derivation of the filtered reconstructed luma samples        alfPicture_(L) [x][y], each reconstructed luma sample inside the        current luma coding tree block recPicture_(L) [x][y] is filtered        as follows with x, y=0 . . . CtbSizeY−1:    -   The array of luma filter coefficients f[j] and the array of luma        clipping values c[j] corresponding to the filter specified by        filtIdx[x][y] is derived as follows with j=0 . . . 11:        -   If AlfCtbFiltSetIdxY[xCtb>>Log2CtbSize][yCtb>>Log2CtbSize]            is less than 16, the following applies:

$\begin{matrix}\left. {{{\left. {{{i = {{AlfCtbFiltSetIdxY}\left\lbrack {xCtb} \right.}}}{Log}2{CtbSize}} \right\rbrack\left\lbrack {yCtb} \right.}}{Log}2{CtbSize}} \right\rbrack & \left( {8 - 1172} \right)\end{matrix}$ $\begin{matrix}{{f\lbrack j\rbrack} = {{{AlfFixFiltCoeff}\left\lbrack {{{AlfClassToFiltMap}\lbrack i\rbrack}\lbrack{filtidx}\rbrack} \right\rbrack}\lbrack j\rbrack}} & \left( {8 - 1173} \right)\end{matrix}$ $\begin{matrix}{{c\lbrack j\rbrack} = 2^{BitdepthY}} & \left( {8 - 1174} \right)\end{matrix}$

-   -   -   Otherwise            (AlfCtbFiltSetIdxY[xCtb>>Log2CtbSize][yCtb>>Log2CtbSize] is            greater than or equal to 16, the following applies:

$\begin{matrix}\left. {\left. {{{\left. {{{i = {{slice\_ alf}{\_ aps}{\_ id}{{\_ luma}\left\lbrack {{AlfCtbFiltSetIdxY}\left\lbrack {xCtb} \right.} \right.}}}}{Log}2{CtbSize}} \right\rbrack\left\lbrack {yCtb} \right.}}{Log}2{CtbSize}} \right\rbrack - 16} \right\rbrack & \left( {8 - 1175} \right)\end{matrix}$ $\begin{matrix}{{f\lbrack j\rbrack} = {{{{AlfCoeff}_{L}\lbrack i\rbrack}\left\lbrack {{{filtIdx}\lbrack x\rbrack}\lbrack y\rbrack} \right\rbrack}\lbrack j\rbrack}} & \left( {8 - 1176} \right)\end{matrix}$ $\begin{matrix}{{c\lbrack j\rbrack} = {{{{AlfClip}_{L}\lbrack i\rbrack}\left\lbrack {{{filtIdx}\lbrack x\rbrack}\lbrack y\rbrack} \right\rbrack}\lbrack j\rbrack}} & \left( {8 - 1177} \right)\end{matrix}$

-   -   The luma filter coefficients and clipping values index idx are        derived depending on transposeIdx[x][y] as follows:        -   If transposeIndex[x][y] is equal to 1, the following            applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {9,4,{10},8,1,5,11,7,3,0,2,6} \right\}} & \left( {8 - 1178} \right)\end{matrix}$

-   -   -   Otherwise, if transposeIndex[x][y] is equal to 2, the            following applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {0,3,2,1,8,7,6,5,4,9,10,11} \right\}} & \left( {8 - 1179} \right)\end{matrix}$

-   -   -   Otherwise, if transposeIndex[x][y] is equal to 3, the            following applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {9,8,{10},4,3,7,11,5,1,0,2,6} \right\}} & \left( {8 - 1180} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {0,1,2,3,4,5,6,7,8,9,10,11} \right\}} & \left( {8 - 1181} \right)\end{matrix}$

-   -   The locations (h_(x+i), v_(y+j)) for each of the corresponding        luma samples (x,y) inside the given array recPictufe of luma        samples with i, j=−3 . . . 3 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1 and xCtb+x−PpsVirtualBoundariesPosX[n] is            greater than or equal to 0 and less than 3 for any n=0 . . .            pps_num_ver_virtual_boundaries−1 the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}{}3\left( {{{Pps}{Virtual}{Boundaries}{{PosX}\lbrack n\rbrack}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1182} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1 and PpsVirtualBoundariesPosX[n]−xCtb−x is greater            than 0 and less than 4 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}{}3\left( {0,\ {{{Pps}{Virtual}{Boundaries}{{PosX}\lbrack n\rbrack}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1183} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}{}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1184} \right)\end{matrix}$

-   -   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1 and yCtb+y−PpsVirtualBoundariesPosY[n] is            greater than or equal to 0 and less than 3 for any n=0 . . .            pps_numhor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}{}3\left( {{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1185} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1 and PpsVirtualBoundariesPosY[n]−yCtb−y is greater            than 0 and less than 4 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}{}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1186} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}{}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1187} \right)\end{matrix}$

-   -   -   -   

            -   

            -   

            -   

        -   

    -   The reconstructed sample offsetsr1, r2 and r3 are specified in        Table 8-22 according to the horizontal luma sample position y        and apply VirtualBoundary.

The variable curr is derived as follows:

$\begin{matrix}{{curr} = {{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y}} \right\rbrack}}} & \left( {8 - 1188} \right)\end{matrix}$

-   -   The variable sum is derived as follows:

$\begin{matrix}{{sum} = {{{f\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y + {r3}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y - {r3}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + 1},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - 1},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right){f\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - 1},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + 1},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + 2},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - 2},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + 1},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - 1},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - 1},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + 1},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - 2},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + 2},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + 3},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - 3},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + 2},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - 2},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + 1},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - 1},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)}}} & \left( {8 - 1189} \right)\end{matrix}$ $\begin{matrix}{{sum} = {{curr} + \left( {\left( {{sum} + 64} \right)\operatorname{>>}7} \right)}} & \left( {8 - 1190} \right)\end{matrix}$

-   -   The modified filtered reconstructed luma picture sample        alfPicture_(L)[xCtb+x][yCtb+y] is derived as follows:        -   If pcm_loop_filter_disabled_flag and            pcm_flag[xCtb+x][yCtb+y] are both equal to 1, the following            applies:

$\begin{matrix}{{{alf}{{{Picture}_{L}\left\lbrack {{xCtb} + x} \right\rbrack}\left\lbrack {{yCtb} + y} \right\rbrack}} = {{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y}} \right\rbrack}}} & \left( {8 - 1191} \right)\end{matrix}$

-   -   -   Otherwise (pcm_loop_filter_disabled_flag is equal to 0 or            pcm_flag[x][y] is equal 0), the following applies:

$\begin{matrix}{{{alf}{{{Picture}_{L}\left\lbrack {{xCtb} + x} \right\rbrack}\left\lbrack {{yCtb} + y} \right\rbrack}} = {{Clip}3\left( {0,{\left( {1{\operatorname{<<}{Bit}}{Depth}_{Y}} \right) - 1},{sum}} \right)}} & \left( {8 - 1192} \right)\end{matrix}$

TABLE 8-22 Specification of r1, r2, and r3 according to the horizontalluma sample position y and applyVirtualBoundary condition r1 r2 r3 ( y == CtbSizeY − 5 ∥ ( y = = CtbSizeY − 4 ) && ( applyVirtualBoundary = = 1) 0 0 0 ( y = = CtbSizeY − 6 ∥ ( y = = CtbSizeY − 3 ) && (applyVirtualBoundary = = 1 ) 1 1 1 ( y = = CtbSizeY − 7 ∥ ( y = =CtbSizeY − 2 ) && ( applyVirtualBoundary = = 1 ) 1 2 2 otherwise 1 2 3

8.8.5.4 Coding Tree Block Filtering Process For Chroma Samples

Inputs of this process are:

-   -   a reconstructed chroma picture sample array recPicture prior to        the adaptive loop filtering process,    -   a filtered reconstructed chroma picture sample array alfPicture,    -   a chroma location (xCtbC, yCtbC) specifying the top-left sample        of the current chroma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        chroma picture sample array alfPicture.        The width and height of the current chroma coding tree block        ctbWidthC and ctbHeightC is derived as follows:

$\begin{matrix}{{{ctb}{Width}{}C} = {{Ctb}{Size}{}{Y/{Sub}}{Width}C}} & \left( {8 - 1230} \right)\end{matrix}$ $\begin{matrix}{{{ctb}{Height}{}C} = {{Ctb}{Size}{}{Y/{Sub}}{Height}C}} & \left( {8 - 1231} \right)\end{matrix}$

For the derivation of the filtered reconstructed chroma samplesalfPicture [x][y], each reconstructed chroma sample inside the currentchroma codingtree block recPicture [x][y] is filtered as follows withx=0 . . . ctbWidthC−1, y=0 . . . ctbHeightC−1:

-   -   The locations (h_(x+i),v_(y+j)) for each of the corresponding        chroma samples (x,y) inside the given array recPicture of chroma        samples with i, j=−2 . . . 2 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1 and            xCtbC+x−PpsVirtualBoundariesPosX[n]/SubWidthC is greater            than or equal to 0 and less than 2 for any n=0 . . .            pps_numver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{{PosX}\lbrack n\rbrack}/{Sub}}{Width}C},{{{pic\_ width}{\_ in}{\_ luma}{{\_ samples}/{Sub}}{Width}C} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1232} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1 and PpsVirtualBoundariesPosX[n]/SubWidthC−xCtbC−x            is greater than 0 and less than 3 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{{PosX}\lbrack n\rbrack}/{Sub}}{Width}C} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1233} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{{\_ samples}/{Sub}}{Width}C} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1234} \right)\end{matrix}$

-   -   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1 and            yCtbC+y−PpsVirtualBoundariesPosY[n]/SubHeightC is greater            than or equal to 0 and less than 2 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{{PosY}\lbrack n\rbrack}/{Sub}}{Height}C},{{{pic\_ height}{\_ in}{\_ luma}{{\_ samples}/{Sub}}{Height}C} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1235} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1 and            PpsVirtualBoundariesPosY[n]/SubHeightC−yCtbC−y is greater            than 0 and less than 3 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{{PosY}\lbrack n\rbrack}/{Sub}}{Height}C} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1236} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{{\_ samples}/{Sub}}{Height}C} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1237} \right)\end{matrix}$

-   -   The variable apply VirtualBoundary is derived as follows:        -   -   

            -   

            -   

            -   

        -       -   The reconstructed sample offsets r1 and r2 are specified in        Table 8-22 according to the horizontal luma sample position y        and apply VirtualBoundary.    -   The variable curr is derived as follows:

$\begin{matrix}{{curr} = {{rec}{{Picture}\left\lbrack {h_{x},v_{y}} \right\rbrack}}} & \left( {8 - 1238} \right)\end{matrix}$

-   -   The array of chromafilter coefficients f[j] and the array of        chroma clipping values c[j] is derived as follows with j=0 . . .        5:

$\begin{matrix}{{f\lbrack j\rbrack} = {{Alf}{{{Coeff}_{C}\left\lbrack {{slice\_ alf}{\_ aps}{\_ id}{\_ chroma}} \right\rbrack}\lbrack j\rbrack}}} & \left( {8 - 1239} \right)\end{matrix}$ $\begin{matrix}{{c\lbrack j\rbrack} = {{Alf}{{{Clip}_{C}\left\lbrack {{slice\_ alf}{\_ aps}{\_ id}{\_ chroma}} \right\rbrack}\lbrack j\rbrack}}} & \left( {8 - 1240} \right)\end{matrix}$

-   -   The variable sum is derived as follows:

$\begin{matrix}{{sum} = {{{f\lbrack 0\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 0\rbrack}},{c\lbrack 0\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 0\rbrack}},{c\lbrack 0\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 1\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 1\rbrack}},{c\lbrack 1\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x + 1},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 1\rbrack}},{c\lbrack 1\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x - 1},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 2\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 2\rbrack}},{c\lbrack 2\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 2\rbrack}},{c\lbrack 2\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 3\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 3\rbrack}},{c\lbrack 3\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x - 1},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 3\rbrack}},{c\lbrack 3\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x + 1},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 4\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 4\rbrack}},{c\lbrack 4\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x + 2},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 4\rbrack}},{c\lbrack 4\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x - 2},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 5\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 5\rbrack}},{c\lbrack 5\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x + 1},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 5\rbrack}},{c\lbrack 5\rbrack},{{{rec}{{Picture}{}\left\lbrack {h_{x - 1},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)}}} & \left( {8 - 1241} \right)\end{matrix}$ $\begin{matrix}\left. {{{sum} = {{curr} + \left( {{sum} + 64} \right)}}\operatorname{>>}7} \right) & \left( {8 - 1242} \right)\end{matrix}$

-   -   The modified filtered reconstructed chroma picture sample        alfPicture[xCtbC+x][yCtbC+y] is derived as follows:        -   If pcm_loop_filter_disabled_flag and            pcm_flag[(xCtbC+x)*SubWidthC][(yCtbC+y)*SubHeightC] are both            equal to 1, the following applies:

$\begin{matrix}{{{alf}{{{Picture}\left\lbrack {{xCtbC} + x} \right\rbrack}\left\lbrack {{yCtbC} + y} \right\rbrack}} = {{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y}} \right\rbrack}}} & \left( {8 - 1243} \right)\end{matrix}$

-   -   -   Otherwise (pcm_loop_filter_disabled_flag is equal to 0 or            pcm_flag[x][y] is equal 0), the following applies:

$\begin{matrix}{{{alf}{{{Picture}\left\lbrack {{xCtbC} + x} \right\rbrack}\left\lbrack {{yCtbC} + y} \right\rbrack}} = {{Clip}3\left( {0,{\left( {1{\operatorname{<<}{Bit}}{Depth}_{C}} \right) - 1},{sum}} \right)}} & \left( {8 - 1244} \right)\end{matrix}$

2.11 Examples of CTU Processing

According to the current VVC design, if the bottom boundary of one CTBis a bottom boundary of a slice/brick, the ALF virtual boundary handlingmethod is disabled. For example, one picture is split to multiple CTUsand 2 slices as depicted FIG. 19 .

Suppose the CTU size is M×M (e.g., M=64), according to the virtualboundary definition, the last 4 lines within a CTB are treated below avirtual boundary. In hardware implementation, the following apply:

-   -   If the bottom boundary of the CTB is the bottom boundary of a        picture (e.g., CTU-D), it processes the (M+4)×M block including        4 lines from above CTU row and all lines in current CTU.    -   Otherwise, if the bottom boundary of the CTB is the bottom        boundary of a slice (or brick) (e.g., CTU-C) and loop filter        across slice enabled flag (or loop filter across bricks enabled        flag) is equal to 0, it processes the (M+4)×M block including 4        lines from above CTU row and all lines in current CTU.    -   Otherwise, if a CTU/CTB in the first CTU row in a        slice/brick/tile (e.g., CTU-A), it processes the M×(M−4) block        excluding the last 4 lines.    -   Otherwise, if a CTU/CTB in not in the first CTU row of a        slice/brick/tile (e.g., CTU-B) and not in the last CTU row of a        of a slice/brick/tile, it processes the M×M block including 4        lines from above CTU row and excluding the last 4 lines in        current CTU.

FIG. 19 shows an example of processing of CTUs in a picture.

2.12 360-Degree Video Coding

The horizontal wrap around motion compensation in the VTM5 is a360-specific coding tool designed to improve the visual quality ofreconstructed 360-degree video in the equi-rectangular (ERP) projectionformat. In conventional motion compensation, when a motion vector refersto samples beyond the picture boundaries of the reference picture,repetitive padding is applied to derive the values of the out-of-boundssamples by copying from those nearest neighbors on the correspondingpicture boundary. For 360-degree video, this method of repetitivepadding is not suitable, and could cause visual artefacts called “seamartefacts” in a reconstructed viewport video. Because a 360-degree videois captured on a sphere and inherently has no “boundary,” the referencesamples that are out of the boundaries of a reference picture in theprojected domain can always be obtained from neighboring samples in thespherical domain. For a general projection format, it may be difficultto derive the corresponding neighboring samples in the spherical domain,because it involves 2D-to-3D and 3D-to-2D coordinate conversion, as wellas sample interpolation for fractional sample positions. This problem ismuch simpler for the left and right boundaries of the ERP projectionformat, as the spherical neighbors outside of the left picture boundarycan be obtained from samples inside the right picture boundary, and viceversa.

FIG. 20 shows an example of horizontal wrap around motion compensationin VVC.

The horizontal wrap around motion compensation process is as depicted inFIG. 20 . When a part of the reference block is outside of the referencepicture's left (or right) boundary in the projected domain, instead ofrepetitive padding, the “out-of-boundary” part is taken from thecorresponding spherical neighbors that are of the reference picturetoward the right (or left) boundary in the projected domain. Repetitivepadding is only used for the top and bottom picture boundaries. Asdepicted in FIG. 20 , the horizontal wrap around motion compensation canbe combined with the non-normative padding method often used in360-degree video coding In VVC, this is achieved by signaling ahigh-level syntax element to indicate the wrap-around offset, whichshould be set to the ERP picture width before padding; this syntax isused to adjust the position of horizontal wrap around accordingly. Thissyntax is not affected by the specific amount of padding on the left andright picture boundaries, and therefore naturally supports asymmetricpadding of the ERP picture, e.g., when left and right padding aredifferent. The horizontal wrap around motion compensation provides moremeaningful information for motion compensation when the referencesamples are outside of the reference picture's left and rightboundaries.

For projection formats composed of a plurality of faces, no matter whatkind of compact frame packing arrangement is used, discontinuitiesappear between two or more adjacent faces in the frame packed picture.For example, considering the 3×2 frame packing configuration depicted inFIG. 24 , the three faces in the top half are continuous in the 3Dgeometry, the three faces in the bottom half are continuous in the 3Dgeometry, but the top and bottom halves of the frame packed picture arediscontinuous in the 3D geometry. If in-loop filtering operations areperformed across this discontinuity, face seam artifacts may becomevisible in the reconstructed video.

To alleviate face seam artifacts, in-loop filtering operations may bedisabled across discontinuities in the frame-packed picture. A syntaxwas proposed to signal vertical and/or horizontal virtual boundariesacross which the in-loop filtering operations are disabled. Compared tousing two tiles, one for each set of continuous faces, and to disablein-loop filtering operations across tiles, the proposed signaling methodis more flexible as it does not require the face size to be a multipleof the CTU size.

2.13 Example Sub-Picture Based Motion-Constrained Independent Regions

In some embodiments, the following features are included:

1) Pictures may be divided into sub-pictures.

2) The indication of existence of sub-pictures is indicated in the SPS,along with other sequence-level information of sub-pictures.

3) Whether a sub-picture is treated as a picture in the decoding process(excluding in-loop filtering operations) can be controlled by thebitstream.

4) Whether in-loop filtering across sub-picture boundaries is disabledcan be controlled by the bitstream for each sub-picture. The DBF, SAO,and ALF processes are updated for controlling of in-loop filteringoperations across sub-picture boundaries.

5) For simplicity, as a starting point, the sub-picture width, height,horizontal offset, and vertical offset are signalled in units of lumasamples in SPS. Sub-picture boundaries are constrained to be sliceboundaries.

6) Treating a sub-picture as a picture in the decoding process(excluding in-loop filtering operations) is specified by slightlyupdating the coding_tree_unit( )) syntax, and updates to the followingdecoding processes:

-   -   The derivation process for (advanced) temporal luma motion        vector prediction    -   The luma sample bilinear interpolation process    -   The luma sample 8-tap interpolation filtering process    -   The chroma sample interpolation process

7) Sub-picture IDs are explicitly specified in the SPS and included inthe tile group headers to enable extraction of sub-picture sequenceswithout the need of changing VCL NAL units.

Output sub-picture sets (OSPS) are proposed to specify normativeextraction and conformance points for sub-pictures and sets thereof.

3. TECHNICAL PROBLEMS SOLVED BY THE SOLUTIONS PROVIDED IN THE PRESENTDOCUMENT

The current VVC design has the following problems:

1. The current setting of enabling ALF virtual boundary is dependent onwhether the bottom boundary of a CTB is a bottom boundary of a picture.If it is true, then ALF virtual boundary is disabled, such as CTU-D inFIG. 19 . However, it is possible that a bottom boundary of a CTB isoutside a bottom boundary of a picture, such as 256×240 picture is splitto 4 128×128 CTUs, in this case, the ALF virtual boundary would bewrongly set to true for the last 2 CTUs which has samples outside of thebottom picture boundary.

2. The way for handling ALF virtual boundary is disabled for bottompicture boundary and slice/tile/brick boundary. Disabling VB alongslice/brick boundary may create pipeline bubble or require processing 68lines per Virtual pipeline data units (VPDU, 64×64 in VVC) assuming theLCU size to be 64×64. For example:

a. For decoders not knowing the slice/brick/tile boundaries upfront(w.e. low-delay applications), the ALF line buffers need to be restored.Whether the content in the line buffers get used or not for the ALFfiltering depends on whether the current CTU is also a slice/brick/tileboundary CTU, this information, however, is unknown until the nextslice/brick/tile is decoded.

b. For decoders knowing the slice/brick/tile boundaries upfront, eitherthe decoders need to live with pipeline bubbles (very unlikely) or runthe ALF at a speed of 68 lines per 64×64 VDPU all the time(overprovision), to avoid using the ALF line buffers.

3. Different way s for handling virtual boundary and video unitboundary, e.g., different padding methods are existing. Meanwhile, morethan one padding methods may be performed for a line when it is atmultiple boundaries.

a. In one example, if the bottom boundary of a block is a 360 degreevirtual boundary and ALF virtual boundary is also applied to this block,in this case, the padding method for 360 degree virtual boundary may befirstly applied to generate virtual samples below the 360 degree virtualboundary. Afterwards, these virtual samples located below the 360 degreevirtual boundary are treated as being available. And the ALF 2-sidepadding method may be further applied according to FIGS. 16 A-C. Anexample is depicted in FIG. 25 .

4. The way for handling virtual boundary may be sub-optimal, sincepadded samples are utilized which may be less efficient.

5. When the non-linear ALF is disabled, the MALF and two-side paddingmethods would be able to generate the same results for filtering asample which requires to access samples crossing virtual boundary.However, when the non-linear ALF is enabled, the two methods would bringdifferent results. It would be beneficial to align the two cases.

6. A slice could be a rectangular one, or a non-rectangular one, such asdepicted in FIG. 28 . In this case, for a CTU, it may not coincide withany boundaries (e.g., picture/slice/tile/brick). However, it may need toaccess samples outside the current slice. If filtering crossing theslice boundary (e.g., loop filter across slices enabled flag is false)is disabled, how to perform the ALF classification and filtering processis unknown.

7. A subpicture is a rectangular region of one or more slices within apicture. A subpicture contains one or more slices that collectivelycover a rectangular region of a picture. The syntax table is modified asfollows to include the concept of subpictures (bold, italicized, andunderlined).

7.3.2.3 Sequence Parameter Set RBSP Syntax

Descriptor seq_parameter_set_rbsp( ) {  sps_decoding_parameter_set_idu(4)  sps_video_parameter_set_id u(4)  sps_max_sub_layers_minus1 u(3) sps_reserved_zero_5bits u(5)  profile_tier_level(sps_max_sub_layers_minus1 )  gra_enabled_flag u(1) sps_seq_parameter_set_id ue(v)  chroma_format_idc ue(v)  if(chroma_format_idc == 3 )   separate_colour_plane_flag u(1) pic_width_max_in_luma_samples ue(v)  pic_height_max_in_luma_samplesue(v)  

   

   

   

   

   

   

   

   

   

  

   

  

   

   

   

  

   

  

   

   

  

   

   

   

   bit_depth_luma_minus8 ue (v)  bit_depth_chroma_minus8 ue (v) log2_max_pic_order_cnt_lsb_minus4 ue (v)  if(sps_max_sub_layers_minus1 > 0 )

It is noted that enabling filtering crossing subpictures is controlledfor each subpicture. However, the controlling of enabling filteringcrossing slice/tile/brick is controlled in picture level which issignaled once to control all slices/tiles/bricks within one picture.

8. ALF classification is performed in 4×4 unit, that is, all sampleswithin one 4×4 unit share the same classification results. However, tobe more precise, samples in a 8×8 window containing current 4×4 blockneed to calculate their gradients. In this case, 10×10 samples need tobe accessed, as depicted in FIG. 30 . If some of the samples are locatedin different video unit (e.g, differentslice/tile/brick/subpicture/above or left or right or bottom “360virtual boundary”/above or below “ALF virtual boundary”), how tocalculate classification need to be defined.

9. In the VVC design, the four boundary positions (e.g., leftvertical/right vertical/above horizontal/below horizontal) areidentified. If a sample is located within the four boundary positions,it is marked as available. However, in VVC, a slice could be covering anon-rectangular region, as shown in FIG. 28 . By checking these fourboundaries positions, it may mark a wrong availability result. Forexample, for the blue position in FIG. 28 (top-left point), it is in adifferent slice from the current block (e.g., the block covering the redposition (right-bottom point)) and shall be marked as “unavailable” ifthe loop filter across slices enabled flag is false (e.g., samplesacross slices are not allowed to be used in ALF). However, by onlychecking the left vertical/right vertical/above horizontal/belowhorizontal boundaries of the current block, the blue position will bewrongly marked as “available”.

4. EXAMPLES OF TECHNIQUES AND EMBODIMENTS

The listing below should be considered as examples to explain generalconcepts. The listed techniques should not be interpreted in a narrowway. Furthermore, these techniques can be combined in any manner.

The padding method used for ALF virtual boundaries may be denoted as‘Two-side Padding’ wherein if one sample located at (i,j) is padded,then the corresponding sample located at (m,n) which share the samefilter coefficient is also padded even the sample is available, asdepicted in FIGS. 12-13 .

The padding method used for picture boundaries/360-degree video virtualboundaries, normal boundaries (e.g. top and bottom boundaries) may bedenoted as ‘One-side Padding’ wherein if one sample to be used isoutside the boundaries, it is copied from an available one inside thepicture.

The padding method used for 360-degree video left and right boundariesmay be denoted as ‘wrapping-base Padding’ wherein if one sample to beused is outside the boundaries, it is copied using the motioncompensated results.

In the following discussion, a sample is “at a boundary of a video unit”may mean that the distance between the sample and the boundary of thevideo unit is less or no greater than a threshold. A “line” may refer tosamples at one same horizontal position or samples at one same verticalposition. (e.g., samples in the same row and/or samples in the samecolumn). Function Abs(x) is defined as follows:

${{Abs}(x)} = \left\{ {\begin{matrix}{x;} & {x>=0} \\{{- x};} & {x < 0}\end{matrix}.} \right.$

In the following discussion, a “virtual sample” refers to a generatedsample which may be different from the reconstructed sample (may beprocessed by deblocking and/or SAO). A virtual sample may be used toconduct ALF for another sample. The virtual sample may be generated bypadding.

‘ALF virtual boundary handling method is enabled for one block’ mayindicate that applyVirtualBoundary in the specification is set to true.‘Enabling virtual boundary’ may indicate that the current block is splitto at least two parts by a virtual boundary and the samples located inone part are disallowed to utilize samples in the other part in thefiltering process (e.g, ALF). The virtual boundary may be K rows abovethe bottom boundary of one block.

In the following descriptions, the neighboring samples may be thosewhich are required for the filter classification and/or filteringprocess.

In the disclosure, a neighbouring sample is “unavailable” if it is outof the current picture, or current sub-picture, or current tile, orcurrent slice, or current brick, or current CTU, or current processingunit (such as ALF processing unit or narrow ALF processing unit), or anyother current video unit.

-   -   1. The determination of ‘The bottom boundary of the current        coding tree block is the bottom boundary of the picture’ is        replaced by ‘The bottom boundary of the current coding tree        block is the bottom boundary of the picture or outside the        picture’.        -   a. Alternatively, furthermore, in this case, the ALF virtual            boundary handling method may be disabled.    -   2. Whether to enable the usage of virtual samples (e.g., whether        to enable virtual boundary (e.g., set applyVirtualBoundary to        true or false)) in the in-loop filtering process may depend on        the CTB size.        -   a. In one example, applyVirtualBoundary is always set to            false for a given CTU/CTB size, e.g., for the CTU/CTB size            equal to K×L (e.g., K=L=4).        -   b. In one example, applyVirtualBoundary is always set to            false for certain CTU/CTB sizes no greater than or smaller            than K×L (e.g., K=L=8).        -   c. Alternatively, ALF is disabled for certain CTU/CTB sizes,            such as 4×4, 8×8.    -   3. Whether to enable the usage of virtual samples (e.g, padded        from reconstructed samples) in the in-loop filtering processes        (e.g., ALF) may depend on whether the bottom boundary of the        block is the bottom boundary of a video unit which is in a finer        granularity compared to a picture (e.g., slice/tile/brick) or a        virtual boundary.        -   a. In one example, the ALF virtual boundary handling method            may be enabled (e.g, applyVirtualBoundary is set to true)            for a coding tree block (CTB) if the bottom boundary of the            CTB is the boundary of the video unit or a virtual boundary.            -   i. Alternatively, furthermore, if the bottom boundary is                not a bottom picture boundary or if the bottom boundary                is outside the picture, the above method is enabled.        -   b. When the bottom boundary of the current coding tree block            is one of the bottom virtual boundaries of the picture and            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1, the ALF virtual boundary handling method may            still be enabled (e.g., applyVirtualBoundary is set to            true).        -   c. In one example, whether to enable the ALF virtual            boundary handling method (e.g., value of            applyVirtualBoundary) for a CTB may only depend on the            relationship between the bottom boundary of the CTB and the            bottom boundary of a picture.            -   i. In one example, applyVirtualBoundary is set to false                only if the bottom boundary of the CTB is the bottom                boundary of a picture containing the CTB or if the                bottom boundary is outside the picture.            -   ii. In one example, applyVirtualBoundary is set to true                when the bottom boundary of the CTB is NOT the bottom                boundary of a picture containing the CTB.        -   d. In one example, for when decoding the CTU-C in FIGS.            18A-18C, M×M samples may be filtered with K lines from above            CTU and excluding K lines below the virtual boundary.    -   4. It is proposed to disable the usage of samples across        brick/slice boundaries in the filtering process (e.g., ALF) even        when the signaled controlling usage flags for loop filters        crossing brick/slice boundaries (e.g.,        loop_filter_across_bricks_enabled_flag/loop_filter_across_slices_enabled_flag)        is true.        -   a. Alternatively, furthermore, the signaled            loop_filter_across_bricks_enabled_flag/loop_filter_across_slices_enabled_flag            may only control the filtering process of deblocking filter            and SAO excluding ALF.        -   b. In one example, a virtual sample may be used instead of            the reconstructed sample at the corresponding position to            conduct ALF for another sample.    -   5. When one block (e.g., CTB) contains a sample located at a        boundary of a video unit (such as slice/brick/tile/360-degree        video virtual or normal boundaries boundaries/picture boundary),        how to generate the virtual sample inside or outside the video        unit (e.g., padding methods) for in-loop filtering such as ALF        may be unified for different kinds of boundaries.        -   a. Alternatively, furthermore, the method of virtual            boundaries (e.g., the Two-side Padding method) may be            applied to the block to handle the sample at boundary for            in-loop filtering.        -   b. Alternatively, furthermore, the above methods may be            applied when the block contains a sample located at the            bottom boundary of the video unit.        -   c. In one example, when decoding the K lines of one block,            if the K lines below the virtual boundary of the block            (e.g., the last K lines in CTU-B of FIGS. 17A-17B) and the            bottom boundary of the block is the bottom boundary of a            video unit, virtual samples may be generated in the ALF            classification/filtering process to avoid usage of other            samples outside these K lines, e.g., the Two-side Padding            method may be applied.            -   i. Alternatively, ALF may be disabled for those last K                lines.        -   d. In one example, when one block is at multiple boundaries,            pixels/samples used for ALF classification may be restricted            to not across any of these multiple boundaries.            -   i. In one example, for a sample, if certain neighboring                sample of it is “unavailable” (e.g., across any of the                multiple boundaries), alone or all kinds of                gradients/directionality may not be calculated for the                sample.                -   1. In one example, gradients of the sample may be                    treated as zero.                -   2. In one example, gradients of the sample may be                    treated as “unavailable” and may not be added to the                    activity (e.g., defined in Eq. (8) of section                    2.6.1.1) derived in the ALF classification process.            -   ii. In one example, the activity/directionality derived                in the ALF classification process may be scaled by a                factor when only partial samples used in ALF                classification process are “available” (e.g., not across                any of these boundaries).            -   iii. In one example, for a boundary block, suppose the                gradients/directionality are required to be calculated                for N samples in the ALF classification process, and the                gradients can only be calculated for M samples (e.g., if                certain neighboring sample of a sample is not                “available”, then the gradient cannot be calculated for                it), then the activity may be multiplied by N/M.                -   1. Alternatively, it may be multiplied by a factor                    dependent on N/M. E.g., the number may be of MN (N                    is an integer), for example, M=2.        -   e. In one example, gradients of partial samples in a M×N            (e.g., M=N=8 in current design, M columns and N rows) window            may be used for classification.            -   i. For example, for the current N1*N2 (N1=N2=4 in the                current design) block, the M*N is centered at the N1*N2                block.            -   ii. In one example, gradients of samples that do not                need to access samples across any boundaries may be                used.                -   1. Alternatively, furthermore, when calculating the                    gradient of a sample locating at one or multiple                    boundaries, padding (e.g., 1-side padding) may be                    performed if some neighboring samples of the current                    sample are “unavailable”.                -   2. Alternatively, furthermore, above K (e.g.,                    K=1, 2) unavailable lines may be padded if the                    current sample is located at the top boundary of a                    video unit (such as slice/brick/tile/360-degree                    video virtual boundaries or ALF virtual boundaries).                -   3. Alternatively, furthermore, left K (e.g., K=1, 2)                    unavailable columns may be padded if the current                    sample is located at the left boundary of a video                    unit.                -   4. Alternatively, furthermore, right K (e.g.,                    K=1, 2) unavailable columns may be padded if the                    current sample is located at the right boundary of a                    video unit.                -   5. Alternatively, furthermore, bottom K (e.g.,                    K=1, 2) unavailable lines may be padded if the                    current sample is located at the bottom boundary of                    a video unit.                -   6. Alternatively, furthermore, if the current sample                    is located at the top boundary and the left boundary                    of a video unit, above K1 (e.g, K1=1, 2) unavailable                    lines may be padded first to generate a M*(N+K1)                    window, then, left K2 (e.g., K2=1, 2) unavailable                    columns may be padded to generate a (M+K2)*(N+K1)                    window.                -    a. Alternatively, left K2 (e.g., K2=1, 2)                    unavailable columns may be padded first to generate                    a (M+K2)*N window, then, above K1 (e.g., K1=1, 2)                    unavailable lines may be padded to generate a                    (M+K2)*(N+K1) window.                -   7. Alternatively, furthermore, if the current sample                    is located at the top boundary and the right                    boundary of a video unit, above K1 (e.g., K1=1, 2)                    unavailable lines may be padded first to generate a                    M*(N+K1) window, then, right K2 (e.g., K2=1, 2)                    unavailable columns may be padded to generate a                    (M+K2)*(N+K1) window.                -    a. Alternatively, right K2 (e.g., K2=1, 2)                    unavailable columns may be padded first to generate                    a (M+K2)*N window, then, above K1 (e.g., K1=1, 2)                    unavailable lines may be padded to generate a                    (M+K2)*(N+K1) window.                -   8. Alternatively, furthermore, if the current sample                    is located at the bottom boundary and the right                    boundary of a video unit, bottom K1 (e.g., K1=1, 2)                    unavailable lines may be padded first to generate a                    M*(N+K1) window, then, right K2 (e.g., K2=1, 2)                    unavailable columns may be padded to generate a                    (M+K2)*(N+K1) window.                -    a. Alternatively, right K2 (e.g., K2=1, 2)                    unavailable columns may be padded first to generate                    a (M+K2)*N window, then, bottom K1 (e.g., K1=1, 2)                    unavailable lines may be padded to generate a                    (M+K2)*(N+K1) window.                -   9. Alternatively, furthermore, if the current sample                    is located at the bottom boundary and the left                    boundary of a video unit, bottom K1 (e.g., K1=1, 2)                    unavailable lines may be padded first to generate a                    M*(N+K1) window, then, left K2 (e.g., K2=1, 2)                    unavailable columns may be padded to generate a                    (M+K2)*(N+K1) window.                -    a. Alternatively, left K2 (e.g., K2=1, 2)                    unavailable columns may be padded first to generate                    a (M+K2)*N window, then, bottom K1 (e.g., K1=1, 2)                    unavailable lines may be padded to generate a                    (M+K2)*(N+K1) window.                -   10. Alternatively, furthermore, the padded samples                    may be used to calculate gradients.            -   iii. In one example, for a block at the top/bottom                boundary of a video unit (such as                slice/brick/tile/360-degree video virtual boundaries or                ALF virtual boundaries), gradients of samples in a                M*(N−C1) window may be used for the classification of                the block.                -   1. Alternatively, furthermore, gradients of the                    top/bottom C1 lines of the M*N window are not used                    in the classification.            -   iv. In one example, for a block at the left/right                boundary of a video unit, gradients of samples in a                (M−C1)*N window may be used for the classification of                the block.                -   1. Alternatively, furthermore, gradients of the                    left/right C1 columns of the M*N window are not used                    in the classification.            -   v. In one example, for a block at the top boundary and                the bottom boundary of a video unit, gradients of                samples in a M*(N−C1−C2) window may be used for the                classification of the block.                -   1. Alternatively, furthermore, gradients of the top                    C1 lines and the bottom C2 lines of the M*N window                    are not used in the classification.            -   vi. In one example, for a block at the top boundary and                the left boundary of a video unit, gradients of samples                in a (M−C1)*(N−C2) window may be used for the                classification of the block.                -   1. Alternatively, furthermore, gradients of the top                    C1 lines and the left C2 columns of the M*N window                    are not used in the classification.            -   vii. In one example, for a block at the top boundary and                the right boundary of a video unit, gradients of samples                in a (M−C1)*(N−C2) window may be used for the                classification of the block.                -   1. Alternatively, furthermore, gradients of the top                    C1 lines and the right C2 columns of the M*N window                    are not used in the classification.            -   viii. In one example, for a block at the bottom boundary                and the left boundary of a video unit, gradients of                samples in a (M−C1)*(N−C2) window may be used for the                classification of the block.                -   1. Alternatively, furthermore, gradients of the                    bottom C1 lines and the left C2 columns of the M*N                    window are not used in the classification.            -   ix. In one example, for a block at the bottom boundary                and the right boundary of a video unit, gradients of                samples in a (M−C1)*(N−C2) window may be used for the                classification of the block.                -   1. Alternatively, furthermore, gradients of the                    bottom C1 lines and the right C2 columns of the M*N                    window are not used in the classification.            -   x. In one example, for a block at the left boundary and                the right boundary of a video unit, gradients of samples                in a (M−C1−C2)*N window may be used for the                classification of the block.                -   1. Alternatively, furthermore, gradients of the left                    C1 columns and the right C2 columns of the M*N                    window are not used in the classification.            -   xi. In one example, for a block at the top boundary, the                bottom boundary and the left boundary of a video unit,                gradients of samples in a (M−C3)*(N−C1−C2) window may be                used for the classification of the block.                -   1. Alternatively, furthermore, gradients of the top                    C1 lines, and the bottom C2 lines and the left C3                    columns of the M*N window are not used in the                    classification.            -   xii. In one example, for a block at the top boundary,                the bottom boundary and the right boundary of a video                unit, gradients of samples in a (M−C3)*(N−C1−C2) window                may be used for the classification of the block.                -   1. Alternatively, furthermore, gradients of the top                    C1 lines, and the bottom C2 lines and the right C3                    columns of the M*N window are not used in the                    classification.            -   xiii. In one example, fora block at the left boundary,                the right boundary and the top boundary of a video unit,                gradients of samples in a (M−C1−C2)*(N−C3) window may be                used for the classification of the block.                -   1. Alternatively, furthermore, gradients of the left                    C1 columns, and the right C2 columns and the top C3                    lines of the M*N window are not used in the                    classification.            -   xiv. In one example, for a block at the left boundary,                the right boundary and the bottom boundary of a video                unit, gradients of samples in a (M−C1−C2)*(N−C3) window                may be used for the classification of the block.                -   1. Alternatively, furthermore, gradients of the left                    C1 columns, and the right C2 columns and the bottom                    C3 lines of the M*N window are not used in the                    classification.            -   xv. In one example, for a block at the left boundary,                the right boundary, the top boundary and the bottom                boundary of a video unit, gradients of samples in a                (M−C1−C2)*(N−C3−C4) window may be used for the                classification of the block.                -   1. Alternatively, furthermore, gradients of the left                    C1 columns, and the right C2 columns, the top C3                    lines and the bottom C4 lines of the M*N window are                    not used in the classification.            -   xvi. In one example, C1, C2, C3 and C4 are equal to 2.            -   xvii. In one example, gradients of samples that do not                have any “unavailable” neighboring samples required in                the gradient calculation may be used.        -   f. In one example, when one line is at multiple boundaries            (e.g., the distance between the line to the boundary is less            than a threshold), the padding process is performed only            once regardless how many boundaries it may belong to.            -   i. Alternatively, furthermore, how many neighboring                lines shall be padded may be dependent on the position                of the current line relative to all the boundaries.            -   ii. For example, how many neighboring lines shall be                padded may be decided by the distances between the                current line and the two boundaries, such as when the                current line is within two boundaries, with the two                boundaries being above and below.            -   iii. For example, how many neighboring lines shall be                padded may be decided by the distance between the                current line and the nearest boundary, such as when the                current line is within two boundaries, with the two                boundaries being above and below.            -   iv. For example, how many neighboring lines shall be                padded may be calculated for each boundary                independently, and the maximum one is selected as the                final padded line number.            -   v. In one example, how many neighboring lines shall be                padded may be decided for each side (e.g., the above                side and the below side) of the line.            -   vi. In one example, for the two-side padding method, how                many neighboring lines shall be padded may be decided                jointly for the two sides.            -   vii. Alternatively, furthermore, the 2-side padding                method used by ALF is applied.        -   g. In one example, when one line is at multiple boundaries            and there is at least one boundary in each side (e.g., the            above side and the below side) of the line, ALF may be            disabled for it.        -   h. In one example, when the number of the padded lines            required by the current line is larger than a threshold, ALF            may be disabled for the current line.            -   i. In one example, when the number of the padded lines                in any side is larger than a threshold, ALF may be                disabled for the current line.            -   ii. In one example, when the total number of the padded                lines in both sides is larger than a threshold, ALF may                be disabled for the current line.        -   i. Alternatively, furthermore, the above methods may be            applied when the block contains a sample located at the            bottom boundary of the video unit and the in-loop filtering            such as ALF is enabled for the block.        -   j. Alternatively, furthermore, the above methods may be            applied under certain conditions, such as when the block            contains a sample located at the bottom boundary of the            video unit and filtering crossing the boundaries is            disallowed (e.g.,            pps_loop_filter_across_virtual_boundaries_disabled_flag/loop_filter_across_slices_enabled_flag/loop_filter_across_slices_enabled_fl            ag is true).        -   k. Proposed method is also applicable to samples/blocks            located at vertical boundaries.    -   6. When a sample is of at least two boundaries of one block        (e.g., at least one which is above current line is the ALF        Virtual boundary, and below is the other boundary), how many        lines to be padded is not purely decided by the distance between        current line relative to the ALF virtual boundary. Instead, it        is determined by the distances between current line relative to        the two boundaries.        -   a. In one example, the number of lines for per-side padding            is set to (M−min (D0, D1)).        -   b. In one example, the number of lines for per-side padding            is set to (M−max (D0, D1)).        -   c. For above example, D0, D1 denote the distance between            current line and the above/below boundaries.        -   d. For above example, M denote the number of lines that ALF            virtual boundary is from the bottom of one CTU.    -   7. At least two ways of selecting samples in the ALF        classification and/or ALF linear or non-linear filtering process        may be defined, with one of them selects samples before any        in-loop filtering method is applied; and the other selects        samples after one or multiple in-loop filtering methods are        applied but before ALF is applied.        -   a. In one example, the selection of different ways may            depend on the location of samples to be filtered.        -   b. In one example, a sample at the bottom boundary of a            video unit (such as CM) may be selected with the first            method when it is used in ALF for another sample. Otherwise            (it is not at the boundary), the second method is selected.    -   8. It is proposed to disable the usage of samples crossing a        VPDU boundary (e.g., a 64×64 region) in the filtering process.        -   a. In one example, when a sample required by the ALF            classification process is outside the VPDU boundary, or            below the virtual boundary, it may be replaced by a virtual            sample or the classification results for the sample may be            copied from that associated with other samples, such as            padded from available ones.        -   b. In one example, when a sample required by a filtering            process is outside the VPDU boundary, or below the virtual            boundary, it may be replaced by a virtual sample, such as            padded from available ones.        -   c. In one example, the ALF virtual boundary handling method            may be enabled (e.g, apply VirtualBoundary is set to true)            for a block if it contains samples located at the boundary            of a VPDU.        -   d. Alternatively, usage of samples crossing a horizontal            VPDU boundary may be disabled in the filtering process.            -   i. In one example, when a sample required by a filtering                process is below the horizontal VPDU boundary, or below                the virtual boundary, it may be replaced by a virtual                sample, such as padded from available ones.        -   e. Alternatively, usage of samples crossing a vertical VPDU            boundary may be disabled in the filtering process.            -   i. In one example, when a sample required by a filtering                process is outside the vertical VPDU boundary, or below                the virtual boundary, it may be replaced by a virtual                sample, such as padded from available ones.    -   9. Instead of using padded samples (e.g., not unavailable,        above/below virtual boundaries, above/below boundaries of a        video unit) in the ALF classification/filtering process, it is        proposed to use the reconstructed samples before all in-loop        filters.        -   a. Alternatively, furthermore, the concept of two-side            padding is applied via padding samples from the            reconstructed samples before all in-loop filters.            -   i. In one example, if a sample in a filter support is                from reconstructed samples before all in-loop filters,                the symmetric (e.g., symmetrical about the origin, e.g.,                the current sample) sample in the filter support shall                also uses the reconstructed one before all in-loop                filters.                -   1. Suppose the coordinate of the current sample to                    be filtered is (0, 0) and the sample located at                    (i,j) is the reconstructed one before all in-loop                    filters, then the sample located at (−i, −j) is the                    reconstructed one before all in-loop filters.                -   2. Suppose the coordinate of the current sample to                    be filtered is (x,y) and the sample located at (x+i,                    y+j) is the reconstructed one before all in-loop                    filters, then the sample located at (x−i, y−j) is                    the reconstructed one before all in-loop filters.        -   b. Alternatively, furthermore, when In-loop reshaping            (a.k.aLMCS) is enabled, the reconstructed samples before all            in-loop filters are those in the original domain converted            from the reshaped domain.    -   10. Instead of using padded samples (e.g., not unavailable,        above/below virtual boundaries, above/below boundaries of a        video unit) in the ALF filtering process, it is proposed to        employ different ALF filter supports.        -   a. In one example, suppose a sample needs to be padded in            the above method, instead of performing the padding, filter            coefficient associated with the sample is set to be zero.            -   i. In this case, the filter support is modified by                excluding samples which require to be padded.            -   ii. Alternatively, furthermore, the filter coefficients                applied to other samples except the current sample is                kept unchanged, however, the filter coefficient applied                to current sample may be modified, such as                ((1<<C_BD)−sum of all filter coefficients applied to                samples which don't need to be padded) wherein C_BD                indicates the filter coefficient's bit-depth.                -   1. Taking FIGS. 18A-18B for example, when filtering                    lines L and I, the filter coefficient c12 applied to                    current sample is modified to be                    ((1<<C_BD)−2*(c4+c5+c6+c7+c8+c9+c10+c11)).        -   b. In one example, suppose a sample (x1, y1) is padded from            (x2, y2) in above method, instead of performing the padding,            filter coefficient associated with (x1, y1) is added to that            of the position (x2, y2) regardless the non-linear filter is            enabled or disabled.        -   i. Alternatively, furthermore, the clipping parameter for            (x2, y2) may be derived on-the-fly.            -   1. In one example, it may be set equal to the decoded                clipping parameter for (x2, y2).            -   2. Alternatively, it may be set to the returned value of                a function with the decoded clipping parameters for (x1,                y1) and (x2, y2) as inputs, such as larger value or                smaller value.    -   11. Selection of clipping parameters/filter coefficients/filter        supports may be dependent on whether filtering a sample need to        access padded samples (e.g., not unavailable, above/below        virtual boundaries, above/below boundaries of a video unit).        -   a. In one example, different clipping parameters/filter            coefficients/filter supports may be utilized for samples            with same class index but for some of them require accessing            padded samples and other don't.        -   b. In one example, the clipping parameters/filter            coefficients/filter supports for filtering samples which            require to access padded samples may be signaled in            CTU/region/slice/tile level.        -   c. In one example, the clipping parameters/filter            coefficients/filter supports for filtering samples which            require to access padded samples may be derived from that            used for filtering samples which don't require to access            padded samples.            -   i. In one example, bullets 9 a or 9 b may be applied.    -   12. How to handle a sample at a boundary for in-loop filtering        (such as ALF) may depend on the color component and/or color        format.        -   a. For example, the definition of “at boundary” may be            different for different color components. In one example, a            luma sample is at the bottom boundary if the distance            between it and the bottom boundary is less than T1; a chroma            sample is at the bottom boundary if the distance between it            and the bottom boundary is less than T2. T1 and T2 may be            different.            -   i. In one example, T1 and T2 may be different when the                color format is not 4:4:4.    -   13. When bottom/top/left/right boundary of one CTU/VPDU is also        a boundary of a slice/tile/brick/sub-region with independent        coding, a fixed order of multiple padding processes is applied.        -   a. In one example, in a first step, the padding method            (e.g., 1-side padding) of slice/tile/brick is firstly            applied. Afterwards, the padding method for handling ALF            virtual boundaries (e.g., 2-side padding method) is further            applied during a second step. In this case, the padded            samples after the first step are marked as available and may            be used to decide how many lines to be padded in the ALF            virtual boundary process. The same rule (e.g., FIGS.            16A-16C) for handling CTUs which are not located at those            boundaries are utilized.    -   14. The proposed methods may be applied to one or multiple        boundaries between two sub-pictures.        -   a. The boundary applying the proposed methods may be a            horizontal boundary.        -   b. The boundary applying the proposed methods may be a            vertical boundary.    -   15. The above proposed methods may be applied to samples/blocks        at vertical boundaries.    -   16. Whether or/and how proposed method is applied at “360        virtual boundary” may be dependent on the position of the “360        virtual boundary”.        -   a. In one example, when the “360 virtual boundary” coincides            with a CTU boundary, proposed method may be applied. E.g.,            Only the 2-side padding may be applied in ALF for samples at            “360 virtual boundary”.        -   b. In one example, when the “360 virtual boundary” does not            coincide with a CTU boundary, proposed method may not be            applied. E.g., only the 1-side padding may be applied in ALF            for samples at “360 virtual boundary”.        -   c. In one example, same padding method may be applied in ALF            for samples at the “360 virtual boundary” regardless the            position of the “360 virtual boundary”.            -   i. For example, the 1-side padding may be applied in ALF                for samples at “360 virtual boundary”.            -   ii. For example, the 2-side padding may be applied in                ALF for samples at “360 virtual boundary”.        -   d. In one example, for samples at multiple boundaries            wherein at least one boundary is a “360 virtual boundary”            and at least one of the “360 virtual boundary” does not            coincide with a CTU boundary, proposed method may not be            applied.            -   i. For example, samples across any of these multiple                boundaries may be padded by 1-side padding.                -   1. Alternatively, furthermore, if there is a                    “virtual boundary”, 2-side padding may be applied in                    ALF after the 1-side padding.        -   e. In one example, for samples located between two kinds of            boundaries, if one of them is the “360 virtual boundary”,            and the other is not, padding is invoked only once in the            ALF process.            -   i. In one example, the padding method for handling ALF                virtual boundaries (e.g., the 2-side padding method) may                be invoked.                -   1. Alternatively, the padding method for handling                    picture (or slice/tile/brick/sub-picture) boundaries                    (e.g., 1-side padding) may be invoked.            -   ii. Alternatively, two or multiple padding processes may                be applied in order.                -   1. In one example, the padding method for handling                    picture (or slice/tile/brick/sub-picture) boundaries                    (e.g., 1-side padding) may be firstly applied,                    afterwards, the padding method for handling ALF                    virtual boundaries (e.g., the 2-side padding method)                    may be further invoked.                -    a. Alternatively, furthermore, the padded samples                    after the first padding are treated as available in                    the second padding process.            -   iii. In one example, for samples located between two or                more kinds of boundaries, (e.g, slice boundary/tile                boundary/brick boundary/360 virtual boundary”/“ALF                virtual boundary”/sub-picture boundary), if only one of                the boundaries is the “360 virtual boundary” (as shown                in FIG. 24 , for example, the first boundary is the “360                virtual boundary”, and the second boundary is a “ALF                virtual boundary” or slice/brick/tile                boundary/sub-picture boundary; or vice versa), proposed                method may be applied. E.g, only the 2-side padding may                be applied in ALF for these samples.                -   1. Alternatively, if these multiple kinds of                    boundaries are either“360 virtual boundary” or                    picture boundary, proposed method may not be                    applied. E.g., only the 1-side padding may be                    applied in ALF for these samples.            -   f. In one example, for samples located between two or                more kinds of boundaries, and if at least one of the                boundaries is the “360 virtual boundary” and it does not                coincide with the CTU boundary, proposed method may not                be applied.                -   i. In this case, it may be treated as prior art for                    handling samples only at “360 virtual boundary” but                    not at other kinds of boundaries.                -   ii. In one example, only the 1-side padding may be                    applied in ALF for these samples.            -   g. In one example, for samples located between two or                more kinds of boundaries, and if at least one of the                boundaries is the “360 virtual boundary”, proposed                method may not be applied.                -   i. In this case, it may be treated as prior art for                    handling samples only at “360 virtual boundary” but                    not at other kinds of boundaries.                -   ii. In one example, only the 1-side padding may be                    applied in ALF for these samples.    -   17. When a reference sample required in the ALF filtering        process (e.g., P0i with i being A/B/C/D in FIG. 16C when        filtering the current sample P0) or/and the ALF classification        process is “unavailable”, e.g., due to that the sample is        located in a different video unit (e.g.,        slice/brick/tile/sub-picture) from the current sample and        filtering using samples across the video unit (e.g.,        slice/brick/tile/sub-picture boundaries) is disallowed, the        “unavailable” sample may be padded with “available” samples        (e.g., samples within the same slice/brick/tile/sub-picture with        the current sample).        -   a. In one example, the “unavailable” reference sample may be            first clipped to its nearest “available” horizontal            position, then, the “unavailable” reference sample is            clipped to its nearest “available” vertical position if            necessary.        -   b. In one example, the “unavailable” reference sample may be            first clipped to its nearest “available” vertical position,            then, the “unavailable” sample is clipped to its nearest            “available” horizontal position if necessary.        -   c. In one example, the coordinate of a “unavailable”            reference sample is clipped to the coordinate of its nearest            “available” sample (e.g., smallest distance) in horizontal            direction.            -   i. In one example, for two samples with coordinators                (x1, y1) and (x2, y2), the horizontal distance between                them may be calculated as Abs(x1−x2).        -   d. In one example, the coordinate of a “unavailable”            reference sample is clipped to the coordinate of its nearest            “available” sample (e.g., smallest distance) in vertical            direction.            -   i. In one example, for two samples with coordinators                (x1, y1) and (x2, y2), the vertical distance between                them may be calculated as Abs(y1−y2).        -   e. In one example, the “unavailable” sample is clipped to            its nearest “available” sample (e.g., smallest distance).            -   i. In one example, for two samples with coordinators                (x1, y1) and (x2, y2), the distance between them may be                calculated as (x1−x2)*(x1−x2)+(y1−y2)*(y1−y2).            -   ii. Alternatively, the distance between the two pixels                may be calculated as Abs(x1−x2)+Abs(y1−y2).        -   f. In one example, the “unavailable” sample may be padded in            a predefined order until a “available” sample is found. An            example is shown in FIG. 31 , wherein Cur is the current            block/CU/PU/CTU.            -   i. For example, vertical “available” sample may be first                checked, then, horizontal “available” sample may be                checked.            -   ii. For example, horizontal “available” sample may be                first checked, then, vertical “available” sample may be                checked.            -   iii. For example, for the “unavailable” above-left                neighboring samples (e.g, in region “1”), first, the                left neighboring samples (e.g., in region “4”) of the                current block/CU/PU/CTU are checked, if there are no                “available” samples, the above neighboring samples                (e.g., in region “2”) are then checked. If there are no                “available” samples in neither left neighboring samples                nor above neighboring samples, the top-left sample of                the current block/CU/PU/CTU is used to pad the                “unavailable” sample.                -   1. Alternatively, for the “unavailable” above-left                    neighboring samples, the above neighboring samples                    of the current block/CU/PU/CTU are checked, if there                    are no “available” samples, the left neighboring                    samples are then checked. If there are no                    “available” samples in neither above neighboring                    samples nor left neighboring samples, the top-left                    sample of the current block/CU/PU/CTU is used to pad                    the “unavailable” sample.            -   iv. For example, for the “unavailable” above-right                neighboring samples (e.g, in region “3”), first, the                right neighboring samples (e.g., in region “5”) of the                current block/CU/PU/CTU are checked, if there are no                “available” samples, the above neighboring samples                (e.g., in region “2”) are then checked. If there are no                “available” samples in neither right neighboring samples                nor above neighboring samples, the top-right sample of                the current block/CU/PU/CTU is used to pad the                “unavailable” sample.                -   1. Alternatively, for the “unavailable” above-right                    neighboring samples, first, the above neighboring                    samples of the current block/CU/PU/CTU are checked,                    if there are no “available” sample, the right                    neighboring samples are then checked. If there are                    no “available” samples in neither above neighboring                    samples nor right neighboring samples, the top-right                    sample of the current block/CU/PU/CTU is used to pad                    the “unavailable” sample.            -   v. For example, for the “unavailable” below-left                neighboring samples (e.g, in region “6”), first, the                left neighboring samples (e.g., in region “4”) of the                current block/CU/PU/CTU are checked, if there are no                “available” sample, the below neighboring samples (e.g.,                in region “7”) are then checked. If there are no                “available” samples in neither left neighboring samples                nor below neighboring samples, the bottom-left sample of                the current block/CU/PU/CTU is used to pad the                “unavailable” sample.                -   1. Alternatively, for the “unavailable” below-left                    neighboring samples, first, the below neighboring                    samples of the current block/CU/PU/CTU are checked,                    if there are no “available” sample, the left                    neighboring samples are then checked. If there are                    no “available” samples in neither below neighboring                    samples nor left neighboring samples, the                    bottom-left sample of the current block/CU/PU/CTU is                    used to pad the “unavailable” sample.            -   vi. For example, for the “unavailable” below-right                neighboring samples, first, the right neighboring                samples (e.g., in region “5”) of the current                block/CU/PU/CTU are checked, if there are no “available”                sample, the below neighboring samples (e.g., in region                “7”) are then checked. If there are no “available”                samples in neither right neighboring samples nor below                neighboring samples, the bottom-right sample of the                current block/CU/PU/CTU is used to pad the “unavailable”                sample.                -   1. For example, for the “unavailable” below-right                    neighboring samples, first, the below neighboring                    samples of the current block/CU/PU/CTU are checked,                    if there are no “available” sample, the right                    neighboring samples are then checked. If there are                    no “available” samples in neither below neighboring                    samples nor right neighboring samples, the                    bottom-right sample of the current block/CU/PU/CTU                    is used to pad the “unavailable” sample.            -   vii. In one example, for each neighboring region, one or                multiple samples may be checked in order. Alternatively,                only one may be checked.            -   viii. Alternatively, furthermore, if none of the                checking could find an available sample, the value of                the current sample to be filtered may be used instead.            -   ix. In one example, for the “unavailable”                above-left/above-right/below-left/below-right                neighboring samples, they may be always padded by                samples within the current block/CU/PU/CTU.                -   1. In one example, for the “unavailable” above-left                    neighboring samples (e.g., in region “1” in FIG. 31                    ), the top-left sample of the current                    block/CU/PU/CTU is used to pad the “unavailable”                    sample.                -   2. In one example, for the “unavailable” above-right                    neighboring samples (e.g., in region “3” in FIG. 31                    ), the top-right sample of the current                    block/CU/PU/CTU is used to pad the “unavailable”                    sample.                -   3. In one example, for the “unavailable” below-left                    neighboring samples (e.g., in region “6” in FIG. 31                    ), the bottom-left sample of the current                    block/CU/PU/CTU is used to pad the “unavailable”                    sample.                -   4. In one example, for the “unavailable” below-right                    neighboring samples (e.g., in region “8” in FIG. 31                    ), the bottom-right sample of the current                    block/CU/PU/CTU is used to pad the “unavailable”                    sample.        -   g. Alternatively, filtering process is disabled for the            current sample.        -   h. Alternatively, the classification process in ALF (e.g.,            gradient calculation for current sample) may be disallowed            to use the unavailable reference samples.    -   18. How to derive the padded sample of unavailable reference        samples may depend on whether the CTU coincides with any        boundaries.        -   a. In one example, when current CTU does not coincide with            any kinds of boundaries, but filtering process (e.g., ALF            classification/ALF filtering process) for a current sample            need to access a reference sample in a different video unit            (e.g., slice), methods described in bullet 16 may be            applied.            -   i. Alternatively, furthermore, when current CTU does not                coincide with any kinds of boundaries, but filtering                process (e.g., ALF classification/ALF filtering process)                for a current sample need to access a reference sample                in a different video unit (e.g., slice) and filtering                crossing a slice boundary is disallowed, methods                described in bullet 16 may be applied.            -   ii. Alternatively, furthermore, when current CTU does                not coincide with any kinds of boundaries, but filtering                process (e.g., ALF classification/ALF filtering process)                for a current sample need to access a reference sample                in a different video unit (e.g., slice) and a reference                sample in the same video unit and filtering crossing a                slice boundary is disallowed, methods described in                bullet 16 may be applied.        -   b. In one example, when current CTU coincides with at least            one kind of boundary, unified padding methods may be applied            (e.g., 2-side or 1-side padding).            -   i. Alternatively, when current CTU coincides with                multiple kinds of boundaries and filtering crossing                those boundaries is disallowed, unified padding methods                may be applied (e.g., 2-side or 1-side padding).        -   c. In one example, only “unavailable” samples that cannot be            padded by 2-side padding or/and 1-side padding may be padded            using methods described in bullet 16.    -   19. Whether the filtering process (e.g., deblocking, SAO, ALF,        bilateral filtering, Hadamard transform filtering etc.) can        access samples across boundaries of a video unit (e.g.,        slice/brick/tile/sub-picture boundary) may be controlled at        different levels, such as being controlled by itself, instead of        being controlled for all video units in a sequence/picture.        -   a. Alternatively, one syntax element may be signaled for a            slice in PPS/slice header to indicate whether the filtering            process can across the slice boundary for the slice.        -   b. Alternatively, one syntax element may be signaled for a            brick/tile in PPS to indicate whether the filtering process            can across the brick/tile boundary for the brick/tile.        -   c. In one example, syntax elements may be signaled in            SPS/PPS to indicate whether the filtering process can across            the brick boundary or/and tile boundary or/and slice            boundary or/and “360-degree virtual boundary” for the            video/picture.            -   i. In one example, separate syntax elements may be                signaled for different kinds of boundaries.            -   ii. In one example, one syntax element may be signaled                for all kinds of boundaries.            -   iii. In one example, one syntax element may be signaled                for several kinds of boundaries.                -   1. For example, 1 syntax element may be signaled for                    both brick boundary and tile boundary.        -   d. In one example, syntax element may be signaled in SPS to            indicate whether there are PPS/slice level indications on            the filtering process.            -   i. In one example, separate syntax elements may be                signaled for different kinds of boundaries.            -   ii. In one example, one syntax element may be signaled                for all kinds of boundaries.            -   iii. In one example, one syntax element may be signaled                for several kinds of boundaries.                -   1. For example, 1 syntax element may be signaled for                    both brick boundary and tile boundary.            -   iv. Indications on whether the filtering process can                across the slice/brick/tile/sub-picture boundary may be                signaled in PPS/slice header only when the corresponding                syntax element in SPS is equal to a certain value.                -   1. Alternatively, indications on whether the                    filtering process can across the                    slice/brick/tile/sub-picture boundary may not be                    signaled in PPS/slice header when the corresponding                    syntax element in SPS is equal to certain values.                -    a. In this case, the filtering process may not be                    allowed to across the slice/brick/tile/sub-picture                    boundary if the indication in SPS is equal to a                    certain value.                -    b. In this case, the filtering process may across                    the slice/brick/tile/sub-picture boundary if the                    indication in SPS is equal to a certain value.    -   20. It is proposed to check whether samples located at        above-left/above-right/below-left/below-right neighboring        regions of current block are in the same video unit (e.g.,        slice/brick/tile/subpicture/360 virtual boundaries) as the        current block in the ALF processes (e.g., classification and/or        filtering processes). Denote the top-left sample of the current        luma coding tree block relative to the top left sample of the        current picture by (x0, y0), denote ctbXSize and ctbYSize as the        CTU width and height respectively.        -   a. In one example, a representative sample located at            above-left region, such as (x0−offsetX0, y0−offsetY0) may be            checked.            -   i. In one example, (offsetX0, offsetY0) may be equal to                (1, 1), (2, 1) or (1, 2).        -   b. In one example, a representative sample located at            above-right region, such as (x0+offsetX1, y0−offsetY1) may            be checked.            -   i. In one example, (offsetX1, offsetY1) may be equal to                (ctbXSize, 1), (ctbXSize+1, 1) or (ctbXSize, 2).        -   c. In one example, a representative sample located at            below-left region, such as (x0 offsetX2, y0+offsetY2) may be            checked.            -   i. In one example, (offsetX2, offsetY2) may be equal to                (1, ctbYSize), (2, ctbYSize) or (1, ctbYSize+1).        -   d. In one example, a representative sample located at            below-right region, such as (x0+offsetX3, y0+offsetY3) may            be checked.            -   i. In one example, (offsetX2, offsetY2) may be equal to                (ctbXSize, ctbYSize), (ctbXSize+1, ctbYSize) or                (ctbXSize, ctbYSize+1).        -   e. In one example, if the representative sample in a region            is in a different video unit, and filtering crossing            different video unit is disallowed, then a sample to be            accessed in the region is marked as unavailable.            -   i. In one example, if the representative sample in a                region is in a different slice, and                loop_filter_across_slices_enabled_flag is equal to 0,                then a sample to be accessed in the region is marked as                unavailable.            -   ii. In one example, if the representative sample in a                region is in a different brick, and                loop_filter_across_bricks_enabled_flag is equal to 0,                then a sample to be accessed in the region is marked as                unavailable.            -   iii. In one example, if the representative sample in a                region is in a different subpicture, and                loop_filter_across_subpic_enabled_flag[SubPicIdx] is                equal to 0, then a sample to be accessed in the region                is marked as unavailable. In one example, the SubPicIdx                is the index of current sub picture including the                current block.        -   f. In above examples, offsetX1/offsetY1 (with i being 0 . .            . 3) are integers.            -   i. Alternatively, furthermore, offsetX1/offsetY1 (with i                being 0 . . . 3) may be set equal to the CTU                width/height.    -   21. The above proposed methods may be applied not only to ALF,        but also to other kinds of filtering methods that require to        access samples outside current block.        -   a. Alternatively, the above proposed methods may be applied            to other coding tools (non-filtering methods) that require            to access samples outside current block    -   22. Whether to and/or how to apply the above methods may be        determined by:        -   a. A message signaled in the DPS/SPS/VPS/PPS/APS/picture            header/slice header/tile group header/Largest coding unit            (LCU)/Coding unit (CU)/LCU row/group of LCUs/TU/PU            block/Video coding unit        -   b. Position of CU/PU/TU/block/Video coding units        -   c. Block dimension of current block and/or its neighboring            blocks        -   d. Block shape of current block and/or its neighboring            blocks        -   e. Coded information of the current block and/or its            neighboring blocks        -   f. Indication of the color format (such as 4:2:0, 4:4:4)        -   g. Coding tree structure        -   h. Slice/tile group type and/or picture type        -   i. Color component (e.g. may be only applied on chroma            components or luma component)        -   j. Temporal layer ID        -   k. Profiles/Levels/Tiers of a standard

5. EMBODIMENTS

In the sections below, some examples of how current version of the VVCstandard be modified to accommodate some embodiments of disclosedtechnology is described. Newly added parts are indicated in bolditalicized underlined text. The deleted parts are indicated using [[ ]].

5.1 Embodiment #1

loop_filter_across_bricks_enabled_flag equal to 1 specifies that in-loopfiltering operations may be performed across brick boundaries inpictures referring to the PPS. loop_filter_across_bricks_enabled_flagequal to 0 specifies that in-loop filtering operations are not performedacross brick boundaries in pictures referring to the PPS. The in-loopfiltering operations include the deblocking filter, sample adaptiveoffset filter[[, and adaptive loop filter]] operations. When notpresent, the value of loop_filter_across_bricks_enabled_flag is inferredto be equal to 1.loop_filter_across_slices_enabled_flag equal to 1 specifies that in-loopfiltering operations may be performed across slice boundaries inpictures referring to the PPS. loop_filter_across_slice_enabled_flagequal to 0 specifies that in-loop filtering operations are not performedacross slice boundaries in pictures referring to the PPS. The in-loopfiltering operations include the deblocking filter, sample adaptiveoffset filter[[, and adaptive loop filter]] operations. When notpresent, the value of loop_filter_across_slices_enabled_flag is inferredto be equal to 0.

5.2 Embodiment #2

FIG. 21 shows processing of CTUs in a picture. The differences comparedto FIG. 19 highlighted with the dashed lines.

5.3 Embodiment #3 8.8.5.2 Coding Tree Block Filtering Process for LumaSamples

Inputs of this process are:

-   -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process,    -   a filtered reconstructed luma picture sample array        alfPicture_(L),    -   a luma location (xCtb,yCtb) specifying the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        luma picture sample array alfPicture_(L).        The derivation process for filter index clause 8.8.5.3 is        invoked with the location (xCtb,yCtb) and the reconstructed luma        picture sample array recPicture_(L) as inputs, and filtIdx[x][y]        and transposeIdx[x][y] with x, y=0 . . . CtbSizeY−1 as outputs.        For the derivation of the filtered reconstructed luma samples        alfPicture_(L)[x][y], each reconstructed luma sample inside the        current luma coding tree block recPicture_(L)[x][y] is filtered        as follows with x, y=0 . . . CtbSizeY−1:    -   The array of luma filter coefficients f[j] and the array of luma        clipping values c[j] corresponding to the filter specified by        filtIdx[x][y] is derived as follows with j=0 . . . 11:        -   . . .    -   The luma filter coefficients and clipping values index idx are        derived depending on transposeIdx[x][y] as follows:        -   . . .    -   The locations (h_(x+i), v_(y+j)) for each of the corresponding        luma samples (x,y) inside the given array recPicture of luma        samples with i, j=−3 . . . 3 are derived as follows:        -   . . .    -   The variable applyVirtualBoundary is derived as follows:        -   If [[one or more of]] the following condition[[s are]] is            true, applyVirtualBoundary is set equal to 0:            -   The bottom boundary of the current coding tree block is                the bottom boundary of the picture.            -   [[The bottom boundary of the current coding tree block                is the bottom boundary of the brick and                loop_filter_across_bricks_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the slice and                loop_filter_across_slices_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                one of the bottom virtual boundaries of the picture and                pps_loop_filter_across_virtual_boundaries_disabled_flag                is equal to 1.]]        -   Otherwise, applyVirtualBoundary is set equal to 1.    -   The reconstructed sample offsets r1, r2 and r3 are specified in        Table 8-22 according to the horizontal luma sample position y        and apply VirtualBoundary.    -   . . .

8.8.5.4 Coding Tree Block Filtering Process for Chroma Samples

Inputs of this process are:

-   -   a reconstructed chroma picture sample array recPicture prior to        the adaptive loop filtering process,    -   a filtered reconstructed chroma picture sample array alfPicture,    -   a chroma location (xCtbC, yCtbC) specifying the top-left sample        of the current chroma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        chroma picture sample array alfPicture.        The width and height of the current chroma coding tree block        ctbWidthC and ctbHeightC is derived as follows:

$\begin{matrix}{{{ctb}{Width}C} = {{Ctb}{Size}{Y/{Sub}}{Width}C}} & \left( {8 - 1230} \right)\end{matrix}$ $\begin{matrix}{{{ctb}{Height}C} = {{Ctb}{Size}{Y/{Sub}}{Height}{}C}} & \left( {8 - 1231} \right)\end{matrix}$

For the derivation of the filtered reconstructed chroma samplesalfPicture[x][y], each reconstructed chroma sample inside the currentchroma coding tree block recPicture [x][y] is filtered as follows withx=0 . . . ctbWidthC−1, y=0 . . . ctbHeightC−1:

-   -   The locations (h_(x+i), v_(y+j)) for each of the corresponding        chroma samples (x,y) inside the given array recPicture of chroma        samples with i, j=−2 . . . 2 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1 and xCtbC+x            PpsVirtualBoundariesPosX[n]/SubWidthC is greater than or            equal to 0 and less than 2 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{{PpsVirtualBoundariesPosX}\lbrack n\rbrack}/{SubWidthC}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1232} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1 and PpsVirtualBoundariesPosX[n]/SubWidthC−xCtbC−x            is greater than 0 and less than 3 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{{PpsVirtualBoundariesPosX}\lbrack n\rbrack}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1233} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1234} \right)\end{matrix}$

-   -   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1 and            yCtbC+y−PpsVirtualBoundariesPosY[n]/SubHeightC is greater            than or equal to 0 and less than 2 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{{PpsVirtualBoundariesPosY}\lbrack n\rbrack}/{SubHeightC}},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{SubHeightC}} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1235} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1 and            PpsVirtualBoundariesPosY[n]/SubHeightC−yCtbC−y is greater            than 0 and less than 3 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{{PpsVirtualBoundariesPosY}\lbrack n\rbrack}/{SubHeightC}} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1236} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{SubHeightC}} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1237} \right)\end{matrix}$

-   -   The variable apply VirtualBoundary is derived as follows:        -   If [[one or m ore of]] the following condition [[s are]] is            true, applyVirtualBoundary is set equal to 0:            -   The bottom boundary of the current coding tree block is                the bottom boundary of the picture.            -   [[The bottom boundary of the current coding tree block                is the bottom boundary of the brick and                loop_filter_across_bricks_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the slice and                loop_filter_across_slices_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                one of the bottom virtual boundaries of the picture and                pps_loop_filter_across_virtual_boundaries_disabled_flag                is equal to 1.]]        -   Otherwise, applyVirtualBoundary is set equal to 1.    -   The reconstructed sample offsets r1 and r2 are specified in        Table 8-22 according to the horizontal luma sample position y        and apply VirtualBoundary.

Alternatively, the condition “the bottom boundary of the currentcodingtree block is the bottom boundary of the picture” can be replacedby “the bottom boundary of the current coding tree block is the bottomboundary of the picture or outside the picture.”

5.4 Embodiment #4

This embodiment shows an example of disallowing using samples below theVPDU region in the ALF classification process (corresponding to bullet 7in section 4).

8.8.5.3 Derivation Process for ALF Transpose and Filterindex for LumaSamples

Inputs of this process are:

-   -   a luma location (xCtb,yCtb) specifying the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture,    -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process.        Outputs of this process are    -   the classification filter index array filtIdx[x][y] with x, y=0        . . . CtbSizeY−1,    -   the transpose index array transposeIdx[x][y] with x, y=0 . . .        CtbSizeY−1.        The locations (h_(x+i), v_(y+j)) for each of the corresponding        luma samples (x,y) inside the given array recPicture of luma        samples with i,j=−2 . . . 5 are derived as follows:    -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1 and xCtb+x−PpsVirtualBoundariesPosX[n] is greater        than or equal to 0 and less than 2 for any n=0 . . .        pps_numver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{PpsVirtualBoundariesPosX}\lbrack n\rbrack},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1193} \right)\end{matrix}$

-   -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1 and PpsVirtualBoundariesPosX[n]−xCtb−x is greater than 0        and less than 6 for any n=0 . . .        pps_numver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{PpsVirtualBoundariesPosX}\lbrack n\rbrack} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1194} \right)\end{matrix}$

-   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1195} \right)\end{matrix}$

-   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1 and yCtb+y−PpsVirtualBoundariesPosY[n] is greater        than or equal to 0 and less than 2 for any n=0 . . .        pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{PpsVirtualBoundariesPosY}\lbrack n\rbrack},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1196} \right)\end{matrix}$

-   -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1 and PpsVirtualBoundariesPosY[n]−yCtb−y is greater than 0        and less than 6 for any n=0 . . .        pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{PpsVirtualBoundariesPosY}\lbrack n\rbrack} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1197} \right)\end{matrix}$

-   -   Otherwise, the following applies:        -   If yCtb+CtbSizeY is greater than or equal to            pic_height_in_luma_samples, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1198} \right)\end{matrix}$

-   -   -   Otherwise, if y is less than CtbSizeY−4, the following            applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{yCtb} + {CtbSizeY} - 5},{{yCtb} + y + j}} \right)}} & \left( {8 - 1199} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{yCtb} + {CtbSizeY} - 4},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1200} \right)\end{matrix}$

The classification filter index array filtIdx and the transpose indexarray transposeIdx are derived by the following ordered steps:

-   -   1. The variables filtH[x][y], filtV[x][y], filtD0[x][y] and        filtD1[x][y] with x, y=−2 . . . CtbSizeY+1 are derived as        follows:        -   If both x and y are even numbers or both x and y are uneven            numbers, the following applies:

$\begin{matrix}{{{{filtH}\lbrack x\rbrack}\lbrack y\rbrack} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x - 1},v_{y}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x + 1},v_{y}} \right\rbrack}} \right)}} & \left( {8 - 1201} \right)\end{matrix}$ $\begin{matrix}{{{{filtV}\lbrack x\rbrack}\lbrack y\rbrack} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8 - 1202} \right)\end{matrix}$ $\begin{matrix}{{{filtD}{{0\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x - 1},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x + 1},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8 - 1203} \right)\end{matrix}$ $\begin{matrix}{{{filtD}{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x + 1},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x - 1},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8 - 1204} \right)\end{matrix}$

-   -   -   Otherwise, filtH[x][y], filtV[x][y], filtD0[x][y] and            filtD1[x][y] are set equal to 0.

    -   2. The variables minY,maxY and ac are derived as follows:        -   If (y<<2) is equal to            [[(CtbSizeY−8)]] and (yCtb+CtbSizeY) is less than            pic_height_in_luma_samples−1, minY is set equal to −2, maxY            is set equal to 3 and ac is set equal to 96.        -   Otherwise, if (y<<2) is equal to            [[(CtbSizeY−4)]] and (yCtb+CtbSizeY) is less than            pic_height_in_luma_samples−1, minY is set equal to 0, maxY            is set equal to 5 and ac is set equal to 96.        -   Otherwise, minY is set equal to 2 and maxY is set equal to 5            and ac is set equal to 64.

    -   3. The variables varTempH1[x][y], varTempV1[x][y],        varTempD01[x][y], varTempD11 [x][y] and varTemp[x][y] with x,        y=0 . . . (CtbSizeY−1)>>2 are derived as follows:

$\begin{matrix}{{{{{sumH}\lbrack x\rbrack}\lbrack y\rbrack} = {{\sum_{i}{\sum_{j}{{{{filtH}\left\lbrack {h_{{({x \ll 2})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y \ll 2})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {{- 2}\ldots 5}}},{j = {\min Y\ldots{\max Y}}}} & \left( {8 - 1205} \right)\end{matrix}$ $\begin{matrix}{{{{{sumV}\lbrack x\rbrack}\lbrack y\rbrack} = {{\sum_{i}{\sum_{j}{{{{filtV}\left\lbrack {h_{{({x \ll 2})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y \ll 2})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {{- 2}\ldots 5}}},{j = {{\min Y}\ldots{\max Y}}}} & \left( {8 - 1206} \right)\end{matrix}$ $\begin{matrix}{{{{sumD}{{0\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filtD}{{0\left\lbrack {h_{{({x \ll 2})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y \ll 2})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {{- 2}\ldots 5}}},{j = {{\min Y}\ldots{\max Y}}}} & \left( {8 - 1207} \right)\end{matrix}$ $\begin{matrix}{{{{sumD}{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filtD}{{1\left\lbrack {h_{{({x \ll 2})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y \ll 2})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {{- 2}\ldots 5}}},{j = {{\min Y}\ldots{\max Y}}}} & \left( {8 - 1208} \right)\end{matrix}$ $\begin{matrix}{{{{sumOfHV}\lbrack x\rbrack}\lbrack y\rbrack} = {{{{sumH}\lbrack x\rbrack}\lbrack y\rbrack} + {{{sumV}\lbrack x\rbrack}\lbrack y\rbrack}}} & \left( {8 - 1209} \right)\end{matrix}$

-   -   4. The variables dir1[x][y], dir2[x][y] and dirS[x][y] with x,        y=0 . . . CtbSizeY−1 are derived as follows:        -   The variables hv1,hv0 and dirHV are derived as follows:            -   . . .        -   The variables d1, d0 and dirD are derived as follows:            -   . . .    -   5. The variable avgVar[x][y] with x,y=0 . . . CtbSizeY−1 is        derived as follows:

$\begin{matrix}{{{varTab}\left\lbrack \right\rbrack} = \left\{ {0,1,2,2,2,2,2,3,3,3,3,3,3,3,3,4} \right\}} & \left( {8 - 1227} \right)\end{matrix}$ $\begin{matrix}{{{{{avgVar}\lbrack x\rbrack}\lbrack y\rbrack} = {VarTab}}\text{ }\left\lbrack {{Clip}3\left( {0,15,{\left( {{{{sumOfHV}\left\lbrack {x \gg 2} \right\rbrack}\left\lbrack {y \gg 2} \right\rbrack}*{ac}} \right) \gg \left( {3 + {BitDepth}_{Y}} \right)}} \right)} \right\rbrack} & \left( {8 - 1228} \right)\end{matrix}$

-   -   6. The classification filter index array filtIdx[x][y] and the        transpose index array transposeIdx[x][y] with x=y=0 . . .        CtbSizeY−1 are derived as follows:

transposeTable[] = {0, 1, 0, 2, 2, 3, 1, 3}transposeIdx[x][y] = transposeTable[dir][x][y] * 2 + (dir2[x][y] ≫ 1)]filtIdx[x][y] = avgVar[x][y]

When dirS[x][y] is not equal 0, filtIdx[x][y] is modified as follows:

$\begin{matrix}{{{{filtIdx}\lbrack x\rbrack}\lbrack y\rbrack}+={\left( {\left( {\left( {{{{dir}{{1\lbrack x\rbrack}\lbrack y\rbrack}}\&}0 \times 1} \right) \ll 1} \right) + {{{dirS}\lbrack x\rbrack}\lbrack y\rbrack}} \right)*5}} & \left( {8 - 1229} \right)\end{matrix}$

5.5 Embodiment #5

For samples locate at multiple kinds of boundaries (e.g., slice/brickboundary, 360-degree virtual boundary), the padding process is onlyinvoked once. And how many lines to be padded per side is dependent onthe location of current sample relative to the boundaries.

In one example, the ALF 2-side padding method is applied. Alternatively,furthermore, In the symmetric 2-side padding method, when a sample is attwo boundaries, e.g., one boundary in the above side and one boundary inthe below side, how many samples are padded is decided by the nearerboundary as shown in FIG. 27 . Meanwhile, when deriving theclassification information, only the 4 lines between the two boundariesin FIG. 27 are used.

FIG. 26 shows an example of the padding methods if 4 lines of samplesare of two boundaries. In one example, the first boundary in FIG. 26 maybe the ALF virtual boundary; the second boundary in FIG. 25 may be theslice/tile/brick boundary or the 360-degree virtual boundary.

5.6 Embodiment #6 8.8.5.2 Coding Tree Block Filtering Process for LumaSamples

Inputs of this process are:

-   -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process,    -   a filtered reconstructed luma picture sample array        alfPicture_(L),    -   a luma location (xCtb,yCtb) specifying the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        luma picture sample array alfPicture_(L).        The derivation process for filter index clause 8.8.5.3 is        invoked with the location (xCtb,yCtb) and the reconstructed luma        picture sample array recPicture_(L) as inputs, and filtIdx[x][y]        and transposeIdx[x][y] with x, y=0 . . . CtbSizeY−1 as outputs.    -   The locations (h_(x+i), v_(y+j)) for each of the corresponding        luma samples (x,y) inside the given array recPicture of luma        samples with i,j=−3 . . . 3 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1 and xCtb+x−PpsVirtualBoundariesPosX[n] is            greater than or equal to 0 and less than 3 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{{Clip}3}\left( {{{PpsVirtual}{{BoundariesPosX}\lbrack n\rbrack}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1197} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1 and PpsVirtualBoundariesPosX[n]−xCtb−x is greater            than 0 and less than 4 for any n=0 . . .            pps_numver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{{Clip}3}\left( {0,{{{PpsVirtual}{{BoundariesPosX}\lbrack n\rbrack}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1198} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{{Clip}3}\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1199} \right)\end{matrix}$

-   -   -   [[If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1 and yCtb+y−PpsVirtualBoundariesPosY[n] is            greater than or equal to 0 and less than 3 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{{Clip}3}\left( {{{PpsVirtual}{{BoundariesPosY}\lbrack n\rbrack}},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1200} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1 and PpsVirtualBoundariesPosY[n]−yCtb−y is greater            than 0 and less than 4 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{{Clip}3}\left( {0,{{{PpsVirtual}{{BoundariesPosY}\lbrack n\rbrack}} - 1},{{yCtb} + y + j}} \right)}} & \left. \left. \left( {8 - 1201} \right) \right\rbrack \right\rbrack\end{matrix}$

-   -   -   [[Otherwise, t]] The following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1202} \right)\end{matrix}$

-   -   [[The variable apply VirtualBoundary is derived as follows:        -   If one or more of the following conditions are true, apply            VirtualBoundary is set equal to 0:            -   The bottom boundary of the current coding tree block is                the bottom boundary of the picture.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the brick and                loop_filter_across_bricks_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the slice and                loop_filter_across_slices_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                one of the bottom virtual boundaries of the picture and                pps_loop_filter_across_virtual_boundaries_disabled_flag                is equal to 1.

Otherwise, applyVirtualBoundary is set equal to 1.]]

TABLE 8-24 Specification of r1, r2, and r3 according to the horizontalluma sample position y and [[applyVirtualBoundary]]  

  condition r1 r2 r3 ( y = = CtbSizeY − 5 ∥ y = = CtbSizeY − 4 ) && (applyVirtualBoundary = = 1 ) 0 0 0 ( y = = CtbSizeY − 6 ∥ y = = CtbSizeY− 3 ) && ( applyVirtualBoundary = = 1 ) 1 1 1 ( y = = CtbSizeY − 7 ∥ y == CtbSizeY − 2 ) && ( applyVirtualBoundary = = 1 ) 1 2 2 otherwise 1 2 3 

   

   

   

   

  

   

   

   

   

   

   

  

   

   

   

   

   

   

  

   

   

   

   

   

   

  

   

   

   

   

  

   

   

  

   

   

   

   

  

   

  

   

  

   

   

   

   

  

   

   

   

   

 

8.8.5.3 Derivation Process for ALF Transpose and Filter Index for LumaSamples

Inputs of this process are:

-   -   a luma location (xCtb, yCtb) specifying the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture,    -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process.        Outputs of this process are    -   the classification filter index array filtIdx[x][y] with x, y=0        . . . CtbSizeY−1,    -   the transpose index array transposeIdx[x][y] with x, y=0 . . .        CtbSizeY−1.        The locations (h_(x+i), v_(y+j)) for each of the corresponding        luma samples (x,y) inside the given array recPicture of luma        samples with i, j=−2 . . . 5 are derived as follows:    -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1 and xCtb+x−PpsVirtualBoundariesPosX[n] is greater        than or equal to 0 and less than 2 for any n=0 . . .        pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{PpsVirtual}{{BoundariesPosX}\lbrack n\rbrack}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1208} \right)\end{matrix}$

-   -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1 and PpsVirtualBoundariesPosX[n]−xCtb−x is greater than 0        and less than 6 for any n=0 . . .        pps_numver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{PpsVirtual}{{BoundariesPosX}\lbrack n\rbrack}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1209} \right)\end{matrix}$

-   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1210} \right)\end{matrix}$

-   -   [[If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1 and yCtb+y−PpsVirtualBoundariesPosY[n] is greater        than or equal to 0 and less than 2 for any n=0 . . .        pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}{}3\left( {{{PpsVirtual}{{BoundariesPosY}\lbrack n\rbrack}},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1211} \right)\end{matrix}$

-   -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1 and PpsVirtualBoundariesPosY[n]−yCtb−y is greater than 0        and less than 6 for any n=0 . . .        pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{PpsVirtual}{{BoundariesPosY}\lbrack n\rbrack}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1212} \right)\end{matrix}$

-   -   Otherwise, the following applies:        -   If yCtb+CtbSizeY is greater than or equal to            pic_height_in_luma_samples, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1213} \right)\end{matrix}$

-   -   -   Otherwise, if y is less than CtbSizeY−4, the following            applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{yCtb} + {{CtbSizeY} - 5}},{{yCtb} + y + j}} \right)}} & \left( {8 - 1214} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}{}3\left( {{{yCtb} + {{CtbSizeY} - 4}},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left. \left. \left( {8 - 1215} \right) \right\rbrack \right\rbrack\end{matrix}$

-   -   

    -   

    -   -   

        -   

    -   -   

        -   

        -               The classification filter index array filtIdx and the            transpose index array transposeIdx are derived by the            following ordered steps:

    -   1. The variables filtH[x][y], filtV[x][y], filtD0[x][y] and        filtD1[x][y] with x,y=−2 . . . CtbSizeY+1 are derived as        follows:        -   If both x and y are even numbers or both x and y are uneven            numbers, the following applies:

$\begin{matrix}{{{{filtH}\lbrack x\rbrack}\lbrack y\rbrack} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x - 1},v_{y}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x + 1},v_{y}} \right\rbrack}} \right)}} & \left( {8 - 1216} \right)\end{matrix}$ $\begin{matrix}{{{{filtV}\lbrack x\rbrack}\lbrack y\rbrack} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8 - 1217} \right)\end{matrix}$ $\begin{matrix}{{{filtD}{{0\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x - 1},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x + 1},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8 - 1218} \right)\end{matrix}$ $\begin{matrix}{{{filtD}{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x + 1},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x - 1},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8 - 1219} \right)\end{matrix}$

-   -   -   Otherwise, filtH[x][y], filtV[x][y], filtD0[x][y] and            filtD1[x][y] are set equal to 0.

    -   2. The variables minY, maxY and a c are derived as follows:        -   If (y<<2) is equal to (CtbSizeY−8) and (yCtb+CtbSizeY) is            less than pic_height_in_luma_samples−1, minY is set equal to            2, maxY is set equal to 3 and ac is set equal to 96.

        -   Otherwise, if (y<<2) is equal to (CtbSizeY−4) and            (yCtb+CtbSizeY) is less than pic_height_in_luma_samples−1,            minY is set equal to 0, maxY is set equal to 5 and ac is set            equal to 96.

        -   

        -   -   

            -   

            -   

        -   -   

            -   

            -   

            -   

            -   

            -   

        -   

        -   [[Otherwise, minY is set equal to −2 and maxY is set equal            to 5 and a c is set equal to 64.]]

    -   3. The variables sumH[x][y], sum V[x][y], sumD0 [x][y], sum D1        [x][y] and sumOfHV[x][y] with x, y=0 . . . (CtbSizeY−1)>>2 are        derived as follows:

$\begin{matrix}{{{{{sumH}\lbrack x\rbrack}\lbrack y\rbrack} = {{\sum_{i}{\sum_{j}{{{{filtH}\left\lbrack {h_{{({x \ll 2})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y \ll 2})} + j} - {yCtb}} \right\rbrack}{with}{}i}}} = {{- 2}\ldots 5}}},{j = {{\min Y}\ldots{\max Y}}}} & \left( {8 - 1220} \right)\end{matrix}$ $\begin{matrix}{{{{{sumV}\lbrack x\rbrack}\lbrack y\rbrack} = {{\sum_{i}{\sum_{j}{{{{filtV}\left\lbrack {h_{{({x \ll 2})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y \ll 2})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {{- 2}\ldots 5}}},{j = {{\min Y}\ldots{\max Y}}}} & \left( {8 - 1221} \right)\end{matrix}$ $\begin{matrix}{{{{sumD}{{0\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filtD}{{0\left\lbrack {h_{{({x \ll 2})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y \ll 2})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {{- 2}\ldots 5}}},{j = {{\min Y}\ldots{\max Y}}}} & \left( {8 - 1222} \right)\end{matrix}$ $\begin{matrix}{{{{sumD}{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filtD}{{1\left\lbrack {h_{{({x \ll 2})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y \ll 2})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {{- 2}\ldots 5}}},{j = {{\min Y}\ldots{\max Y}}}} & \left( {8 - 1223} \right)\end{matrix}$ $\begin{matrix}{{{{sumOfHV}\lbrack x\rbrack}\lbrack y\rbrack} = {{{{sumH}\lbrack x\rbrack}\lbrack y\rbrack} + {{{sumV}\lbrack x\rbrack}\lbrack y\rbrack}}} & \left( {8 - 1224} \right)\end{matrix}$

8.8.5.4 Coding Tree Block Filtering Process for Chroma Samples

Inputs of this process are:

-   -   a reconstructed chroma picture sample array recPicture prior to        the adaptive loop filtering process,    -   a filtered reconstructed chroma picture sample array alfPicture,    -   a chroma location (xCtbC, yCtbC) specifying the top-left sample        of the current chroma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        chroma picture sample array alfPicture.        The width and height of the current chroma coding tree block        ctbWidthC and ctbHeightC is derived as follows:

$\begin{matrix}{{ctbWidthC} = {{CtbSizeY}/{SubWidthC}}} & \left( {8 - 1245} \right)\end{matrix}$ $\begin{matrix}{{ctbHeightC} = {{CtbSizeY}/{SubHeightC}}} & \left( {8 - 1246} \right)\end{matrix}$

For the derivation of the filtered reconstructed chroma samplesalfPicture[x][y], each reconstructed chroma sample inside the currentchroma coding tree block recPicture[x][y] is filtered as follows withx=0 . . . ctbWidthC−1, y=0 . . . ctbHeightC−1:

-   -   The locations (h_(x+i), v_(y)+) for each of the corresponding        chroma samples (x,y) inside the given array recPicture of chroma        samples with i, j=−2 . . . 2 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1 and xCtbC+x            PpsVirtualBoundariesPosX[n]/SubWidthC is greater than or            equal to 0 and less than 2 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{{PpsVirtualBoundariesPosX}\lbrack n\rbrack}/{SubWidthC}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1247} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1 and PpsVirtualBoundariesPosX[n]/SubWidthC−xCtbC−x            is greater than 0 and less than 3 for any n=0 . . .            pps_numver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{{PpsVirtualBoundariesPosX}\lbrack n\rbrack}/{SubWidthC}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1248} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1249} \right)\end{matrix}$

-   -   -   [[If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1 and            yCtbC+y−PpsVirtualBoundariesPosY[n]/SubHeightC is greater            than or equal to 0 and less than 2 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{{Clip}3}\left( {{{{PpsVirtualBoundariesPosY}\lbrack n\rbrack}/{SubHeightC}},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{SubHeightC}} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1250} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1 and            PpsVirtualBoundariesPosY[n]/SubHeightC−yCtbC−y is greater            than 0 and less than 3 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{{Clip}3}\left( {0,{{{{PpsVirtualBoundariesPosY}\lbrack n\rbrack}/{SubHeightC}} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1251} \right)\end{matrix}$

-   -   -   Otherwise, the]]            The following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{SubHeightC}} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1252} \right)\end{matrix}$

-   -   [[The variable apply VirtualBoundary is derived as follows:        -   If one or m ore of the following conditions are true, apply            VirtualBoundary is set equal to 0:            -   The bottom boundary of the current codingtree block is                the bottom boundary of the picture.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the brick and                loop_filter_across_bricks_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the slice and                loop_filter_across_slices_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                one of the bottom virtual boundaries of the picture and                pps_loop_filter_across_virtual_boundaries_disabled_flag                is equal to 1.        -   Otherwise, applyVirtualBoundary is set equal to 1.]]    -   The variable boundaryPos1 and boundaryPos2 are derived by        invoking the vertical boundary position derivation process for        luma samples as specified in 8.8.5.5 with yCtb equal to yCtb and        y equal to y.        -   The variable boundaryPos1 is set equal to            boundaryPos1/SubWidthC.        -   The variable boundaryPos2 is set equal to            boundaryPos2/SubWidthC.    -   The reconstructed sample offsets r1 and r2 are specified in        Table 8-24 according to the horizontal luma sample position y        and apply VirtualBoundary.    -   The variable curr is derived as follows:

$\begin{matrix}{{curr} = {{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack}} & \left( {8 - 1253} \right)\end{matrix}$

-   -   The array of chromafilter coefficients f[j] and the array of        chroma clipping valuesc[j] is derived as follows with j=0 . . .        5:

$\begin{matrix}{{f\lbrack j\rbrack} = {{{AlfCoeff}_{C}\left\lbrack {{slice\_ alf}{\_ aps}{\_ id}{\_ chroma}} \right\rbrack}\lbrack j\rbrack}} & \left( {8 - 1254} \right)\end{matrix}$ $\begin{matrix}{{c\lbrack j\rbrack} = {{{AlfClip}_{C}\left\lbrack {{slice\_ alf}{\_ aps}{\_ id}{\_ chroma}} \right\rbrack}\lbrack j\rbrack}} & \left( {8 - 1255} \right)\end{matrix}$

-   -   The variable sum is derived as follows:

$\begin{matrix}{{sum} = {{{f\lbrack 0\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 0\rbrack}},{c\lbrack 0\rbrack},{{{recPicture}\left\lbrack {h_{x},v_{y + {r2}}} \right\rbrack} - {curr}}} \right)} + {{Clip}{}3\left( {{- {c\lbrack 0\rbrack}},{c\lbrack 0\rbrack},{{{recPicture}\left\lbrack {h_{x},v_{y - {r2}}} \right\rbrack} - {curr}}} \right)}} \right)} + {{f\lbrack 1\rbrack}*\left( {{{{Clip}3}\left( {{- {c\lbrack 1\rbrack}},{c\lbrack 1\rbrack},{{{recPicture}\left\lbrack {h_{x + 1},v_{y + {r1}}} \right\rbrack} - {curr}}} \right)} + {{{Clip}3}\left( {{- {c\lbrack 1\rbrack}},{c\lbrack 1\rbrack},{{{recPicture}\left\lbrack {h_{x - 1},v_{y - {r1}}} \right\rbrack} - {curr}}} \right)}} \right)} + {{f\lbrack 2\rbrack}*\left( {{{{Clip}3}\left( {{- {c\lbrack 2\rbrack}},{c\lbrack 2\rbrack},{{{recPicture}\left\lbrack {h_{x},v_{y + {r1}}} \right\rbrack} - {curr}}} \right)} + {{{Clip}3}\left( {{- {c\lbrack 2\rbrack}},{c\lbrack 2\rbrack},{{{recPicture}\left\lbrack {h_{x},v_{y - {r1}}} \right\rbrack} - {curr}}} \right)}} \right)} + {{f\lbrack 3\rbrack}*\left( {{{{Clip}3}\left( {{- {c\lbrack 3\rbrack}},{c\lbrack 3\rbrack},{{{recPicture}\left\lbrack {h_{x - 1},v_{y + {r1}}} \right\rbrack} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 3\rbrack}},{c\lbrack 3\rbrack},{{{recPicture}\left\lbrack {h_{x + 1},v_{y - {r1}}} \right\rbrack} - {curr}}} \right)}} \right)} + {{f\lbrack 4\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 4\rbrack}},{c\lbrack 4\rbrack},{{{recPicture}\left\lbrack {h_{x + 2},v_{y}} \right\rbrack} - {curr}}} \right)} + {{{Clip}3}\left( {{- {c\lbrack 4\rbrack}},{c\lbrack 4\rbrack},{{{recPicture}\left\lbrack {h_{x - 2},v_{y}} \right\rbrack} - {curr}}} \right)}} \right)} + {{f\lbrack 5\rbrack}*\left( {{{{Clip}3}\left( {{- {c\lbrack 5\rbrack}},{c\lbrack 5\rbrack},{{{recPicture}\left\lbrack {h_{x + 1},v_{y}} \right\rbrack} - {curr}}} \right)} + {{{Clip}3}\left( {{- {c\lbrack 5\rbrack}},{c\lbrack 5\rbrack},{{{recPicture}\left\lbrack {h_{x - 1},v_{y}} \right\rbrack} - {curr}}} \right)}} \right)}}} & \left( {8 - 1256} \right)\end{matrix}$ $\begin{matrix}\left. {{sum} = {{{curr} + \left( {{sum} + 64} \right)} \gg 7}} \right) & \left( {8 - 1257} \right)\end{matrix}$

-   -   The modified filtered reconstructed chroma picture sample        alfPicture[xCtbC+x][yCtbC+y] is derived as follows:        -   If pcm_loop_filter_disabled_flag and            pcm_flag[(xCtbC+x)*SubWidthC][(yCtbC+y)*SubHeightC] are both            equal to 1, the following applies:

$\begin{matrix}{{{alf}{{{Picture}\left\lbrack {{xCtbC} + x} \right\rbrack}\left\lbrack {{yCtbC} + y} \right\rbrack}} = {{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y}} \right\rbrack}}} & \left( {8 - 1258} \right)\end{matrix}$

-   -   -   Otherwise (pcm_loop_filter_disabled_flag is equal to 0 or            pcm_flag[x][y] is equal 0), the following applies:

$\begin{matrix}{{{alf}{{{Picture}\left\lbrack {{xCtbC} + x} \right\rbrack}\left\lbrack {{yCtbC} + y} \right\rbrack}} = {{Clip}3\left( {0,{\left( {1{\operatorname{<<}{Bit}}{Depth}_{C}} \right) - 1},{sum}} \right)}} & \left( {8 - 1259} \right)\end{matrix}$

TABLE 8-25 Specification of r1 and r2 according to the horizontal lumasample position y and applyVirtualBoundary]] [[condition r1 r2 (y = =ctbHeightC − 2 ∥ y = = ctbHeightC − 3 ) && ( applyVirtualBoundary == 1 )0 0 (y = = ctbHeightC − 1 ∥ y = = ctbHeightC − 4 ) && (applyVirtualBoundary == 1 ) 1 1 otherwise 1 2]]

 

 

condition r1 r2 ( y = = boundaryPos1 − 1 ∥ y = = boundaryPos1 ) && 0 0(boundaryPos1> −1 && (boundaryPos2 = = −1 ∥ boundaryPos2 >=boundaryPos1 + 4 ) ) ( y = = boundaryPos1 − 2 ∥ y = = boundaryPos1 + 1 )&& 1 1 (boundaryPos1> −1 && (boundaryPos2 = = −1 ∥ boundaryPos2 >=boundaryPos1 + 4 ) ) ( y = = boundaryPos1 − 1 ∥ y = = boundaryPos1 ∥ y == boundaryPos2 − 1 y = = 0 0 boundaryPos2 ) && (boundaryPos1 > −1 &&boundaryPos2 = = boundaryPos1 + 2 ) ) ( y = = boundaryPos1 − 2 ∥ y = =boundaryPos2 + 1 ) && 1 1 (boundaryPos1> −1 &&boundaryPos2 = =boundaryPos1 + 2 ) ) otherwise 1 2

-   -   

    -   

    -   

    -   

    -   -   

        -   

        -   

    -   -   

        -   -   

        -   -   

        -   -   

        -   -   

        -   -   

            -   

    -   -   -   

        -   

    -   -   

        -   

    -   -   

        -   -   

            -   

5.7 Embodiment #7

For a CTU, it may not coincide with any boundaries (e.g.,picture/slice/tile/brick/sub-picture boundary). However, it may need toaccess samples outside the current unit (e.g.,picture/slice/tile/brick/sub-picture). If filtering crossing the sliceboundary (e.g., loop filter across slices enabled flag is false) isdisabled, we need to pad the sample outside the current unit.

For example, for the sample 2801 (take luma sample for example) in FIG.28 , the samples used in ALF filtering process may be padded as in FIG.29 .

5.8 Embodiment #8

In this embodiment, the following main ideas are applied:

On enabling ALF virtual boundaries:

-   -   For CTUs which are not located in the last CTU row in a picture        (e.g., bottom boundary of CTUs is not bottom boundary of a        picture or exceeds the bottom boundary of a picture), ALF        virtual boundary is enabled, i.e., one CTU may be split to two        or more parts, and samples in one part are disallowed to use        samples in another part.    -   For CTUs which are located in the last CTU row in a picture        (e.g., bottom boundary of CTUs is bottom boundary of a picture        or exceeds the bottom boundary of a picture), ALF virtual        boundary is enabled, i.e., one CTU may be split to two or more        parts, and samples in one part are disallowed to use samples in        another part.

On padding of boundaries (including ALF virtual boundaries,slice/tile/brick/sub-picture boundaries, “360 virtual boundaries”) inthe classification process:

For a sample at one (or multiple kinds of) boundary, when neighboringsamples across the boundary are disallowed to be used, 1-side padding isperformed to pad such neighboring samples.

On padding of boundaries (including ALF virtual boundaries,slice/tile/brick/sub-picture boundaries, “360 virtual boundaries”) inthe ALF filtering process:

-   -   For a sample at one (or multiple kinds of) boundary that is a        slice/tile/brick/sub-picture boundary or a “360 virtual        boundary” that coincides with CTU boundary, when neighboring        samples across the boundary are disallowed to be used, 2-side        padding is performed to pad such neighboring samples.    -   For a sample at one (or multiple kinds of) boundary that is a        picture boundary or a “360 virtual boundary” that does not        coincide with CTU boundary, when neighboring samples across the        boundary are disallowed to be used, 1-side padding is performed        to pad such neighboring samples.

8.8.5.2 Coding Tree Block Filtering Process For Luma Samples

Inputs of this process are:

-   -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process,    -   a filtered reconstructed luma picture sample array        alfPicture_(L),    -   a luma location (xCtb,yCtb) specifying the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        luma picture sample array alfPicture_(L).        The derivation process for filter index clause 8.8.5.3 is        invoked with the location (xCtb, yCtb) and the reconstructed        luma picture sample array recPicture_(L) as inputs, and        filtIdx[x][y] and transposeIdx[x][y] with x, y=0 . . .        CtbSizeY−1 as outputs.        For the derivation of the filtered reconstructed luma samples        alfPicture_(L) [x][y], each reconstructed luma sample inside the        current luma codingtree block recPicture_(L) [x][y] is filtered        as follows with x, y=0 . . . CtbSizeY−1:    -   The array of luma filter coefficients f[j] and the array of luma        clipping values c[j] corresponding to the filter specified by        filtIdx[x][y] is derived as follows with j=0 . . . 11:        -   If AlfCtbFiltSetIdxY[xCtb>>Log2Ctb Size][yCtb>>Log2CtbSize]            is less than 16, the following applies:

$\begin{matrix}{i = {{AlfCtbFilt}{Set}{}{{{IdxY}\left\lbrack {{xCtb}\operatorname{>>}{{Log}2{Ctb}{Size}}}{} \right\rbrack}\left\lbrack {{yCtb}\operatorname{>>}{{Log}2{Ctb}{Size}}}{} \right\rbrack}}} & \left( {8 - 1187} \right)\end{matrix}$ $\begin{matrix}{{f\lbrack j\rbrack} = {{Alf}{Fix}{Filt}{{{Coeff}\left\lbrack {{Alf}{Class}{To}{Filt}{{{Map}\lbrack i\rbrack}\left\lbrack {{filt}{{{Idx}\lbrack x\rbrack}\lbrack y\rbrack}} \right\rbrack}} \right\rbrack}\lbrack j\rbrack}}} & \left( {8 - 1188} \right)\end{matrix}$ $\begin{matrix}{{c\lbrack j\rbrack} = 2^{{Bit}{depth}Y}} & \left( {8 - 1189} \right)\end{matrix}$

-   -   -   Otherwise            (AlfCtbFiltSetIdxY[xCtb>>Log2CtbSize][yCtb>>Log2CtbSize] is            greater than or equal to 16, the following applies:

$\begin{matrix}{i = {{slice\_ alf}{\_ aps}{\_ id}{{\_ luma}\left\lbrack {{{Alf}{Ctb}{Filt}{Set}{{{IdxY}\left\lbrack {{xCtb}\operatorname{>>}{{Log}2{Ctb}{Size}}} \right\rbrack}\left\lbrack {{yCtb}\operatorname{>>}{{Log}2{Ctb}{Size}}} \right\rbrack}} - 16} \right\rbrack}}} & \left( {8 - 1190} \right)\end{matrix}$ $\begin{matrix}{{f\lbrack j\rbrack} = {{Alf}{{{{Coeff}_{L}\lbrack i\rbrack}\left\lbrack {{filt}{{{Idx}\lbrack x\rbrack}\lbrack y\rbrack}} \right\rbrack}\lbrack j\rbrack}}} & \left( {8 - 1191} \right)\end{matrix}$ $\begin{matrix}{{c\lbrack j\rbrack} = {{Alf}{{{{Clip}_{L}\lbrack i\rbrack}\left\lbrack {{filt}{{{Idx}\lbrack x\rbrack}\lbrack y\rbrack}} \right\rbrack}\lbrack j\rbrack}}} & \left( {8 - 1192} \right)\end{matrix}$

-   -   The luma filter coefficients and clipping values index idx are        derived depending on transposeIdx[x][y] as follows:        -   If transposeIndex[x][y] is equal to 1, the following            applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {9,4,{10},8,1,5,11,7,3,0,2,6} \right\}} & \left( {8 - 1193} \right)\end{matrix}$

-   -   -   Otherwise, if transposeIndex[x][y] is equal to 2, the            following applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {0,3,2,1,8,7,6,5,4,9,10,11} \right\}} & \left( {8 - 1194} \right)\end{matrix}$

-   -   -   Otherwise, if transposeIndex[x][y] is equal to 3, the            following applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {9,8,{10},4,3,7,11,5,1,0,2,6} \right\}} & \left( {8 - 1195} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {0,1,2,3,4,5,6,7,8,9,10,11} \right\}} & \left( {8 - 1196} \right)\end{matrix}$

-   -   The locations (h_(x+i),v_(y+j)) for each of the corresponding        luma samples (x,y) inside the given array recPicture of luma        samples with i,j=3 . . . 3 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1            and xCtb+x−PpsVirtualBoundariesPosX[n] is greater than or            equal to 0 and less than 3 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{PosX}\lbrack n\rbrack}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1197} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1            and PpsVirtualBoundariesPosX[n]−xCtb−x is greater than 0 and            less than 4 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}{}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{PosX}\lbrack n\rbrack}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1198} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}{}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1199} \right)\end{matrix}$

-   -   -   [[When loop_filter_across_sub_pic_enabled_flag[SubPicIdx]            for the subpicture containing the luma sample at location            (h_(x), v_(y)) is equal to 0, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}{}3\left( {{{SubPic}{Left}{Boundary}{Pos}},{{Sub}{Pic}{Right}{Boundary}{}{Pos}},h_{x + i}} \right)}} & \left( {8 - 1184} \right)\end{matrix}$

-   -   -   If pps_loopfilter_acrossvirtual boundaries_disabled_flag is            equal to 1            and yCtb+y−PpsVirtualBoundariesPosY[n] is greater than or            equal to 0 and less than 3 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1200} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1            and PpsVirtualBoundariesPosY[n]−yCtb−y is greater than 0 and            less than 4 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1201} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1202} \right)\end{matrix}$

-   -   -   [[When loop_filter_across_sub_pic_enabled_flag[SubPicIdx]            for the subpicture containing the luma sample at location            (h_(x), v_(y)) is equal to 0, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{SubPic}{Top}{Boundary}{Pos}},{{SubPic}{Bot}{Boundary}{Pos}},v_{y + j}} \right)}} & \left( {8 - 1184} \right)\end{matrix}$

-   -   The variable apply VirtualBoundary is derived as follows:        -   If one or more of the following conditions are true, apply            VirtualBoundary is set equal to 0:            -   The bottom boundary of the current coding tree block is                the bottom boundary of the picture.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the brick and                loop_filter_across_bricks_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the slice and                loop_filter_across_slices_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the subpicture and                loop_filter_across_sub_pic_enabled_flag[SubPicIdx] for                the subpicture containing the luma sample at location                (h_(x), v_(y)) is equal to 0.            -   The bottom boundary of the current coding tree block is                one of the bottom virtual boundaries of the picture and                pps_loop_filter_across_virtual_boundaries_disabled_flag                is equal to 1.        -   Otherwise, applyVirtualBoundary is set equal to 1.]]

    -   

    -   The reconstructed sample offsetsr1, r2 and r3 are specified in        Table 8-24 according to the horizontal luma sample position y        and        [[apply VirtualBoundary]].

    -   

    -   The variable curr is derived as follows:

$\begin{matrix}\left. {{curr} = {{rec}{Picture}_{L}\left\{ {h_{x},v_{y}} \right.}} \right\rbrack & \left( {8 - 1203} \right)\end{matrix}$

-   -   The variable sum is derived as follows:

$\begin{matrix}{{sum} = {{{f\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y + {r3}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y - {r3}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {\underline{c}1}},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {\underline{c}1}},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {\underline{c}1}},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {\underline{c}1}},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {\underline{c}2}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {\underline{c}2}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {\underline{c}1}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {\underline{c}1}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {\underline{c}1}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {\underline{c}1}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {\underline{c}2}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {\underline{c}2}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {\underline{c}3}},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {\underline{c}3}},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {\underline{c}2}},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {\underline{c}2}},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {\underline{c}1}},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {\underline{c}1}},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)}}} & \left( {8 - 1204} \right)\end{matrix}$ $\begin{matrix}{{sum} = {{curr} + \left( {\left( {{sum} + 64} \right)\operatorname{>>}7} \right)}} & \left( {8 - 1205} \right)\end{matrix}$

-   -   The modified filtered reconstructed luma picture sample        alfPicture_(L)[xCtb+x][yCtb+y] is derived as follows:        -   If pcm_loop_filter_disabled_flag and            pcm_flag[xCtb+x][yCtb+y] are both equal to 1, the following            applies:

$\begin{matrix}{{{alf}{{{Picture}_{L}\left\lbrack {{xCtb} + x} \right\rbrack}\left\lbrack {{yCtb} + y} \right\rbrack}} = {{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y}} \right\rbrack}}} & \left( {8 - 1206} \right)\end{matrix}$

-   -   -   Otherwise (pcm_loop_filter_disabled_flag is equal to 0 or            pcm_flag[x][y] is equal 0), the following applies:

$\begin{matrix}\left. {{{{alf}{{{Picture}_{L}\left\lbrack {{xCtb} + x} \right\rbrack}\left\lbrack {{yCtb} + y} \right\rbrack}} = {{{Clip}3\left( {0,{1{\operatorname{<<}{Bit}}{Depth}_{Y}}} \right)} - 1}},{sum}} \right) & \left( {8 - 1206} \right)\end{matrix}$

TABLE 8-24 Specification of r1, r2, and r3 according to the horizontalluma sample position y 

   

  [[and applyVirtualBoundary]] [[condition r1 r2 r3 ( y = = CtbSizeY − 5∥ y = = CtbSizeY − 4 ) && ( apply VirtualBoundary = = 1 ) 0 0 0 ( y = =CtbSizeY − 6 ∥ y = = CtbSizeY − 3 ) && ( apply VirtualBoundary = = 1 ) 11 1 ( y = = CtbSizeY − 7 ∥ y = = CtbSizeY − 2 ) && ( applyVirtualBoundary = = 1 ) 1 2 2 otherwise 1 2 3]]  

   

   

   

   

  

   

   

   

   

  

   

   

   

   

  

   

   

   

   

   

  

   

   

   

   

   

   

   

 

TABLE 8-24 Specification of c1, c2, and c3 according to the verticalluma sample position x, clipLeftPos and clipRightPos  

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

 

8.8.5.3 Derivation Process for ALF Transpose and Filter Index for LumaSamples

Inputs of this process are:

-   -   a luma location (xCtb,yCtb) specifying the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture,    -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process.        Outputs of this process are    -   the classification filter index array filtIdx[x][y] with x, y=0        . . . CtbSizeY−1,    -   the transpose index array transposeIdx[x][y] with x, y=0 . . .        CtbSizeY−1.        The locations (h_(x+i), v_(y+j)) for each of the corresponding        luma samples (x,y) inside the given array recPicture of luma        samples with i, j=−2 . . . 5 are derived as follows:    -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1        and xCtb+x−PpsVirtualBoundariesPosX[n] is greater than or equal        to 0 and less than 2 for any n=0 . . .        pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{}{{PosX}\lbrack n\rbrack}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1208} \right)\end{matrix}$

-   -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1        and PpsVirtualBoundariesPosX[n]−xCtb−x is greater than 0 and        less than 6 for any n=0 . . . pps_numver_virtual_boundaries−1,        the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{}{{PosX}\lbrack n\rbrack}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1209} \right)\end{matrix}$

-   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1210} \right)\end{matrix}$

-   -   [[When loop_filter_across_sub_pic_enabled_flag[SubPicIdx] for        the subpicture containing the luma sample at location (h_(x),        v_(y)) is equal to 0, the following applies:

h_(x + i) = Clip3(SubPicLeftBoundaryPos, SubPicRightBoundaryPos, h_(x + i))(8 − 1184)]]

-   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1        and yCtb+y−PpsVirtualBoundariesPosY[n] is greater than or equal        to 0 and less than 2 for any n=0 . . .        pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1211} \right)\end{matrix}$

Otherwise, if pps_loop_filter_across_virtual_boundaries_disabled_flag isequal to 1

and PpsVirtualBoundariesPosY[n]−yCtb−y is greater than 0 and less than 6for any n=0 . . . pps_num_hor_virtual_boundaries−1, the followingapplies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1212} \right)\end{matrix}$

-   -   Otherwise, the following applies:        -   If yCtb+CtbSizeY is greater than or equal to            pic_height_in_luma_samples, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1213} \right)\end{matrix}$

-   -   -   [[Otherwise, if y is less than CtbSizeY−4, the following            applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{yCtb} + {{Ctb}{Size}Y} - 5},{{yCtb} + y + j}} \right)}} & \left( {8 - 1214} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{yCtb} + {{Ctb}{Size}Y} - 4},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1215} \right)\end{matrix}$

-   -   When loop_filter_across_sub_pic_enabled_flag[SubPicIdx] for the        subpicture containing the luma sample at location (h_(x), v_(y))        is equal to 0, the following applies:

$\begin{matrix}\left. \left. {v_{y + j} = {{Clip}3\left( {{{SubPic}{Top}{Boundary}{Pos}},{{SubPic}{Bot}{Boundary}{Pos}},v_{y + j}} \right)}} \right\rbrack \right\rbrack & \left( {8 - 1184} \right)\end{matrix}$

-   -   

    -   

    -   

    -   

    -           The classification filter index array filtIdx and the transpose        index array transposeIdx are derived by the following ordered        steps:

    -   1. The variables filtH[x][y], filtV[x][y], filtD0[x][y] and        filtD1[x][y] with x,y=−2 . . . CtbSizeY+1 are derived as        follows:        -   If both x and y are even numbers or both x and y are uneven            numbers, the following applies:

$\begin{matrix}{{{filt}{{H\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack}{1}} \right) - {{recPicture}\left\lbrack {h_{x - 1},v_{y}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x + 1},v_{y}} \right\rbrack}} \right)}} & \left( {8 - 1216} \right)\end{matrix}$ $\begin{matrix}{{{filt}{{V\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack}{1}} \right) - {{recPicture}\left\lbrack {h_{x},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8 - 1217} \right)\end{matrix}$ $\begin{matrix}{{{filt}D{{0\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack}{1}} \right) - {{recPicture}\left\lbrack {h_{x - 1},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x + 1},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8 - 1218} \right)\end{matrix}$ $\begin{matrix}{{{filt}D{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack}{1}} \right) - {{recPicture}\left\lbrack {h_{x + 1},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x - 1},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8 - 1219} \right)\end{matrix}$

-   -   -   Otherwise, filtH[x][y], filtV[x][y], filtD0[x][y] and            filtD1[x][y] are set equal to 0.

    -   2. [[The variables minY, maxY and ac are derived as follows:

    -   If (y<<2) is equal to (CtbSizeY−8) and (yCtb+CtbSizeY) is less        than pic_height_in_luma_samples−1, minY is set equal to −2, maxY        is set equal to 3 and ac is set equal to 96.

    -   Otherwise, if (y<<2) is equal to (CtbSizeY−4) and        (yCtb+CtbSizeY) is less than pic_height_in_luma_samples−1, minY        is set equal to 0, maxY is set equal to 5 and ac is set equal to        96.]]

    -   3. The variables sumH[x][y], sumV[x][y], sumD0[x][y],        sumD1[x][y] and sumOfHV[x][y] with x, y=0 . . . (CtbSizeY−1) >>2        are derived as follows:

-   -   -   

    -   -   

    -   -   

    -   

-   -   -   

    -   -   

    -   

TABLE 8-24 Specification of ac according to minX, minY, maxX, maxY  

   

   

   

   

   

   

   

   

   

   

   

   

 

$\begin{matrix}{{{{sum}{{H\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filt}{{H\left\lbrack {h_{{({x{2}})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y{2}})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {\underline{\min X\ldots\max X}\left\lbrack \left\lbrack {{- 2}\ldots 5} \right\rbrack \right\rbrack}}},{j = {\min Y\ldots\max Y}}} & \left( {8 - 1220} \right)\end{matrix}$ $\begin{matrix}{{{{sum}{{V\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filt}{{V\left\lbrack {h_{{({x{2}})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y{2}})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {\underline{\min X\ldots\max X}\left\lbrack \left\lbrack {{- 2}\ldots 5} \right\rbrack \right\rbrack}}},{j = {\min Y\ldots\max Y}}} & \left( {8 - 1221} \right)\end{matrix}$ $\begin{matrix}{{{{sum}D{{0\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filt}D{{0\left\lbrack {h_{{({x{2}})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y{2}})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {\underline{\min X\ldots\max X}\left\lbrack \left\lbrack {{- 2}\ldots 5} \right\rbrack \right\rbrack}}},{j = {\min Y\ldots\max Y}}} & \left( {8 - 1222} \right)\end{matrix}$ $\begin{matrix}{{{{sum}D{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filt}D{{1\left\lbrack {h_{{({x{2}})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y{2}})} + j} - {yCtb}} \right\rbrack}{with}i}}} = {\underline{\min X\ldots\max X}\left\lbrack \left\lbrack {{- 2}\ldots 5} \right\rbrack \right\rbrack}}},{j = {\min Y\ldots\max Y}}} & \left( {8 - 1223} \right)\end{matrix}$ $\begin{matrix}{{{sum}{{{OfHV}\lbrack x\rbrack}\lbrack y\rbrack}} = {{{sum}{{H\lbrack x\rbrack}\lbrack y\rbrack}} + {{sum}{{V\lbrack x\rbrack}\lbrack y\rbrack}}}} & \left( {8 - 1224} \right)\end{matrix}$

-   -   4. The variables dir1 [x][y], dir2[x][y] and dirS[x][y] with x,        y=0 . . . CtbSizeY−1 are derived as follows:        -   The variables hv1,hv0 and dirHV are derived as follows:            -   If sumV[x>>2][y>>2] is greater than sumH[x>>2][y>>2],                the following applies:

$\begin{matrix}\left. {{{\left. {{{{{hv}1} = {{sum}{V\left\lbrack x \right.}}}}2} \right\rbrack\left\lbrack y \right.}}2} \right\rbrack & \left( {8 - 1225} \right)\end{matrix}$ $\begin{matrix}\left. {{{\left. {{{{{hv}0} = {{sum}{H\left\lbrack x \right.}}}}2} \right\rbrack\left\lbrack y \right.}}2} \right\rbrack & \left( {8 - 1226} \right)\end{matrix}$ $\begin{matrix}{{dirHV} = 1} & \left( {8 - 1227} \right)\end{matrix}$

-   -   -   -   Otherwise, the following applies:

$\begin{matrix}\left. {{{\left. {{{{{hv}1} = {{sum}{H\left\lbrack x \right.}}}}2} \right\rbrack\left\lbrack y \right.}}2} \right\rbrack & \left( {8 - 1228} \right)\end{matrix}$ $\begin{matrix}\left. {{{\left. {{{{{hv}0} = {{sum}{V\left\lbrack x \right.}}}}2} \right\rbrack\left\lbrack y \right.}}2} \right\rbrack & \left( {8 - 1229} \right)\end{matrix}$ $\begin{matrix}{{dirHV} = 3} & \left( {8 - 1230} \right)\end{matrix}$

-   -   -   The variables d1, d0 and dirD are derived as follows:            -   If sumD0[x>>2][y>>2] is greater than sumD1 [x>>2][y>>2],                the following applies:

$\begin{matrix}\left. {{{\left. {{{{d1} = {{sum}D{0\left\lbrack x \right.}}}}2} \right\rbrack\left\lbrack y \right.}}2} \right\rbrack & \left( {8 - 1231} \right)\end{matrix}$ $\begin{matrix}\left. {{{\left. {{{{d0} = {{sum}D{1\left\lbrack x \right.}}}}2} \right\rbrack\left\lbrack y \right.}}2} \right\rbrack & \left( {8 - 1232} \right)\end{matrix}$ $\begin{matrix}{{dirD} = 0} & \left( {8 - 1233} \right)\end{matrix}$

-   -   -   -   Otherwise, the following applies:

$\begin{matrix}\left. {{{\left. {{{{d1} = {{sum}D{1\left\lbrack x \right.}}}}2} \right\rbrack\left\lbrack y \right.}}2} \right\rbrack & \left( {8 - 1234} \right)\end{matrix}$ $\begin{matrix}\left. {{{\left. {{{{d0} = {{sum}D{0\left\lbrack x \right.}}}}2} \right\rbrack\left\lbrack y \right.}}2} \right\rbrack & \left( {8 - 1235} \right)\end{matrix}$ $\begin{matrix}{{dirD} = 2} & \left( {8 - 1236} \right)\end{matrix}$

-   -   -   The variables hvd1, hvd0, are derived as follows:

$\begin{matrix}{{{hvd}1} = {{\left( {{d1*{hv}0} > {{hv}1*d0}} \right)?d}1:{hv}1}} & \left( {8 - 1237} \right)\end{matrix}$ $\begin{matrix}{{{hvd}0} = {{\left( {{d1*{hv}0} > {{hv}1*d0}} \right)?d}0:{hv}0}} & \left( {8 - 1238} \right)\end{matrix}$

-   -   -   The variables dirS[x][y], dir1 [x][y] and dir2 [x][y]            derived as follows:

$\begin{matrix}{{{dir}{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{\left( {{d1*{hv}0} > {{hv}1*d0}} \right)?{dirD}}:{dirHV}}} & \left( {8 - 1239} \right)\end{matrix}$ $\begin{matrix}{{{dir}{{2\lbrack x\rbrack}\lbrack y\rbrack}} = {{\left( {{d1*{hv}0} > {{hv}1*d0}} \right)?{dirHV}}:{dirD}}} & \left( {8 - 1240} \right)\end{matrix}$ $\begin{matrix}{{{{dirS}\lbrack x\rbrack}\lbrack y\rbrack} = {{\left( {{{hvd}1} > {2*{hvd}0}} \right)?1}:\left( {{\left( {{{hvd}1*2} > {9*{hvd}0}} \right)?2}:0} \right)}} & \left( {8 - 1241} \right)\end{matrix}$

-   -   5. The variable avgVar[x][y] with x, y=0 . . . CtbSizeY−1 is        derived as follows:

$\begin{matrix}{{{varTab}{\lbrack\rbrack}} = \left\{ {0,1,2,2,2,2,2,3,3,3,3,3,3,3,3,4} \right\}} & \left( {8 - 1242} \right)\end{matrix}$ $\begin{matrix}\left. \left. {{\left. {\left. {{{\left. {{{{{{avgVar}\lbrack x\rbrack}\lbrack y\rbrack} = {{varTab}\left\lbrack {{Clip}3\left( {0,15,\left( {{sumOfHV}\left\lbrack x \right.} \right.} \right.} \right.}}}2} \right\rbrack\left\lbrack y \right.}}2} \right\rbrack*ac} \right)}\left( {3 + {BitDepth}_{Y}} \right)} \right) \right\rbrack & \left( {8 - 1243} \right)\end{matrix}$

-   -   6. The classification filter index array filtIdx[x][y] and the        transpose index array transposeIdx[x][y] with x=y=0 . . .        CtbSizeY−1 are derived as follows:

transposeTable[] = {0, 1, 0, 2, 2, 3, 1, 3}transposeIdx[x][y] = transposeTable[dir1[x][y] * 2 + (dir2[x][y]1)]filtIdx[x][y] = avgVar[x][y]

When dirS[x][y] is not equal 0, filtIdx[x][y] is modified as follows:

$\begin{matrix}{{{{filtIdx}\lbrack x\rbrack}\lbrack y\rbrack}+={\left( {\left( {\left( {{{{dir}{{1\lbrack x\rbrack}\lbrack y\rbrack}}\&}0x1} \right){1}} \right) + {{{dirS}\lbrack x\rbrack}\lbrack y\rbrack}} \right)*5}} & \left( {8 - 1244} \right)\end{matrix}$

8.8.5.4 Coding Tree Block Filtering Process for Chroma Samples

Inputs of this process are:

-   -   a reconstructed chroma picture sample array recPicture prior to        the adaptive loop filtering process,    -   a filtered reconstructed chroma picture sample array alfPicture,    -   a chroma location (xCtbC, yCtbC) specifying the top-left sample        of the current chroma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        chroma picture sample array alfPicture.        The width a nd height of the current chroma coding tree block        ctbWidthC and ctbHeightC is derived as follows:

$\begin{matrix}{{ctbWidthC} = {{CtbSizeY}/{SubWidthC}}} & \left( {8 - 1245} \right)\end{matrix}$ $\begin{matrix}{{ctbHeightC} = {{CtbSizeY}/{SubHeightC}}} & \left( {8 - 1246} \right)\end{matrix}$

For the derivation of the filtered reconstructed chroma samplesalfPicture[x][y], each reconstructed chroma sample inside the currentchroma coding tree block recPicture[x][y] is filtered as follows withx=0 . . . ctbWidthC−1, y=0 . . . ctbHeightC−1:

-   -   The locations (h_(x+i), v_(y+j)) for each of the corresponding        chroma samples (x,y) inside the given array recPicture of chroma        samples with i, j=−2 . . . 2 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1            and xCtbC+x PpsVirtualBoundariesPosX[n]/SubWidthC is greater            than or equal to 0 and less than 2 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{PpsVirtua}1{{BoundariesPosX}\lbrack n\rbrack}/{SubWidthC}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1247} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1            and PpsVirtualBoundariesPosX[n]/SubWidthC−xCtbC−x is greater            than 0 and less than 3 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{PpsVirtua}1{{BoundariesPosX}\lbrack n\rbrack}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1248} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1249} \right)\end{matrix}$

-   -   -   [[When loop_filter_across_sub_pic_enabled_flag[SubPicIdx]            for the subpicture containing the luma sample at location            (h_(x),v_(y)) is equal to 0, the following applies:

h_(x + i) = Clip3(SubPicLeftBoundaryPos/SubWidthC, SubPicRightBoundaryPos/SubWidthC, h_(x + i))(8 − 1184)]]

-   -   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1            and yCtbC+y−PpsVirtualBoundariesPosY[n]/SubHeightC is            greater than or equal to 0 and less than 2 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}/{Sub}{Height}C},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{Sub}{Height}C} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1250} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1            and PpsVirtualBoundariesPosY[n]/SubHeightC−yCtbC−y is            greater than 0 and less than 3 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}/{Sub}{Height}C} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1251} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{Sub}{Height}C} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1252} \right)\end{matrix}$

-   -   -   [[When loop_filter_across_sub_pic_enabled_flag[SubPicIdx]            for the subpicture containing the luma sample at location            (h_(x), v_(y)) is equal to 0, the following applies:

v_(y + j) = Clip3(SubPicTopBoundaryPos/SubWidthC, SubPicBotBoundaryPos/SubWidthC, v_(y + j))(8 − 1184)

-   -   The variable apply VirtualBoundary is derived as follows:        -   If one or more of the following conditions are true, apply            VirtualBoundary is set equal to 0:            -   The bottom boundary of the current coding tree block is                the bottom boundary of the picture.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the brick and                loop_filter_across_bricks_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the slice and                loop_filter_across_slices_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the subpicture and                loop_filter_across_sub_pic_enabled_flag[SubPicIdx] for                the subpicture containing the luma sample at location                (h_(x), v_(y)) is equal to 0.            -   The bottom boundary of the current coding tree block is                one of the bottom virtual boundaries of the picture and                pps_loop_filter_across_virtual_boundaries_disabled_flag                is equal to 1.        -   Otherwise, applyVirtualBoundary is set equal to 1.]]

    -   -   

        -   

        -   

        -   

    -   The reconstructed sample offsets r1 and r2 are specified in        Table 8-27 according to the horizontal luma sample position y        [[and apply VirtualBoundary]].

    -   

    -   The variable curr is derived as follows:

$\begin{matrix}{{curr} = {{rec}{{Picture}\left\lbrack {h_{x},v_{y}}\  \right\rbrack}}} & \left( {8 - 1253} \right)\end{matrix}$

The array of chromafilter coefficients f[j] and the array of chromaclipping valuesc[j] is derived as follows with j=0 . . . 5:

$\begin{matrix}{{f\lbrack j\rbrack} = {{Alf}{{{Coeff}_{C}\left\lbrack {{slice\_ alf}{\_ aps}{\_ id}{\_ chroma}} \right\rbrack}\lbrack j\rbrack}}} & \left( {8 - 1254} \right)\end{matrix}$ $\begin{matrix}{{c\lbrack j\rbrack} = {{Alf}{{{Clip}_{C}\left\lbrack {{slice\_ alf}{\_ aps}{\_ id}{\_ chroma}} \right\rbrack}\lbrack j\rbrack}}} & \left( {8 - 1255} \right)\end{matrix}$

-   -   The variable sum is derived as follows:

$\begin{matrix}{{sum} = {{{f\lbrack 0\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 0\rbrack}},{c\lbrack 0\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 0\rbrack}},{c\left\lbrack 0 \right\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 1\rbrack}*\left( {{{Clip}{}3\left( {{- {c\lbrack 1\rbrack}},{c\lbrack 1\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x + {\underline{c}1}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 1\rbrack}},{c\left\lbrack 1 \right\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x - \underline{c1}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 2\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 2\rbrack}},{c\lbrack 2\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 2\rbrack}},{c\left\lbrack 2 \right\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 3\rbrack}*\left( {{{Clip}{}3\left( {{- {c\lbrack 3\rbrack}},{c\lbrack 3\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x - {\underline{c}1}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 3\rbrack}},{c\left\lbrack 3 \right\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x + \underline{c1}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 4\rbrack}*\left( {{{Clip}{}3\left( {{- {c\lbrack 4\rbrack}},{c\lbrack 4\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x + {\underline{c}2}},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 4\rbrack}},{c\left\lbrack 4 \right\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x - {\underline{c}2}},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 5\rbrack}*\left( {{{Clip}{}3\left( {{- {c\lbrack 5\rbrack}},{c\lbrack 5\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x + {\underline{c}1}},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 5\rbrack}},{c\left\lbrack 5 \right\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x - {\underline{c}1}},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)}}} & \left( {8 - 1056} \right)\end{matrix}$ $\begin{matrix}\left. {{{sum} = {{curr} + \left( {{sum} + 64} \right)}}\operatorname{>>}7} \right) & \left( {8 - 1257} \right)\end{matrix}$

-   -   The modified filtered reconstructed chroma picture sample        alfPicture[xCtbC+x][yCtbC+y] is derived as follows:        -   If pcm_loop_filter_disabled_flag and            pcm_flag[(xCtbC+x)*SubWidthC][(yCtbC+y)*SubHeightC] are both            equal to 1, the following applies:

$\begin{matrix}{{{alf}{{{Picture}\left\lbrack {{xCtbC} + x} \right\rbrack}\left\lbrack {{yCtbC} + y} \right\rbrack}} = {{rec}{{{Picture}{}}_{L}\left\lbrack {h_{x},v_{y}} \right\rbrack}}} & \left( {8 - 1258} \right)\end{matrix}$

-   -   -   Otherwise (pcm_loop_filter_disabled_flag is equal to 0 or            pcm_flag[x][y] is equal 0), the following applies:

$\begin{matrix}{{{alf}{{{Picture}\left\lbrack {{xCtbC} + x} \right\rbrack}\left\lbrack {{yCtbC} + y} \right\rbrack}} = {{Clip}3\left( {0,{\left( {1{\operatorname{<<}{Bit}}{Depth}_{C}} \right) - 1},{sum}} \right)}} & \left( {8 - 1259} \right)\end{matrix}$

TABLE 8-27 Specification of r1 and r2 according to the horizontal lumasample position y,  

   

  [[and applyVirtualBoundary]] [[condition r1 r2 ( y = = ctbHeightC − 2∥ y = = ctbHeightC − 3 ) && ( applyVirtualBoundary = = 1 ) 0 0 ( y = =ctbHeightC − 1 ∥ y = = ctbHeightC − 4 ) && ( applyVirtualBoundary = = 1) 1 1 otherwise 1 2]]  

   

   

   

  

   

   

   

  

   

   

   

   

  

   

   

   

   

   

 

TABLE 8-28 Specification of c1 and c2 according to vertical luma sampleposition x, clipLeftPos and clipRightPos  

   

   

   

   

   

   

   

   

   

   

   

   

   

 

-   -   

    -   

    -   

    -   

    -   

    -   

    -   

    -   -   

        -   

        -   

    -   

    -   

    -   -   

        -   

        -   

    -   

    -   -   

        -   

        -   

    -   

    -   -   

        -   

        -   

The specific value −128 used in above embodiment may be replaced byother values, such as −K wherein for example, K is greater than or nosmaller than the number of lines shifted from a CTU bottom boundary(e.g, K=−5).

Alternatively, the conditional check of “PpsVirtualBoundariesPosY[n] isnot equal to pic_height_in_luma_samples−1 or 0” could be further removedbased on that PpsVirtualBoundariesPosY[n] is in the range of 1 toCeil(pic_height_in_luma_samples÷8)−1, inclusive.

Alternatively, one flag may be used to mark whether each sample need tobe handled in a different way if it is located at video unit boundaries.

5.9 Embodiment #9

In this embodiment, the following main ideas are applied:

On enabling ALF virtual boundaries:

-   -   For CTUs which are not located in the last CTU row in a picture        (e.g., bottom boundary of CTUs is not bottom boundary of a        picture or exceeds the bottom boundary of a picture), ALF        virtual boundary is enabled, i.e., one CTU may be split to two        or more parts, and samples in one part are disallowed to use        samples in another part.    -   For CTUs which are located in the last CTU row in a picture        (e.g., bottom boundary of CTUs is bottom boundary of a picture        or exceeds the bottom boundary of a picture), ALF virtual        boundary is enabled, i.e., one CTU may be split to two or more        parts, and samples in one part are disallowed to use samples in        another part.

On padding of boundaries (including ALF virtual boundaries,slice/tile/brick/sub-picture boundaries, “360 virtual boundaries”) inthe classification process:

-   -   For a sample at one (or multiple kinds of) boundary, when        neighboring samples across the boundary are disallowed to be        used, 1-side padding is performed to pad such neighboring        samples.

On padding of boundaries (including ALF virtual boundaries,slice/tile/brick/sub-picture boundaries, “360 virtual boundaries”) inthe ALF filtering process:

-   -   For a sample at one (or multiple kinds of) boundary that is a        slice/tile/brick/sub-picture boundary or a “360 virtual        boundary” that coincides with CTU boundary, when neighboring        samples across the boundary are disallowed to be used, 2-side        padding is performed to pad such neighboring samples.    -   For a sample at one (or multiple kinds of) boundary that is a        picture boundary or a “360 virtual boundary” that does not        coincide with CTU boundary, when neighboring samples across the        boundary are disallowed to be used, 1-side padding is performed        to pad such neighboring samples.

8.8.5.2 Coding Tree Block Filtering Process for Luma Samples

Inputs of this process are:

-   -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process,    -   a filtered reconstructed luma picture sample array        alfPicture_(L),    -   a luma location (xCtb,yCtb) specifying the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        luma picture sample array alfPicture_(L).        The derivation process for filter index clause 8.8.5.3 is        invoked with the location (xCtb,yCtb) and the reconstructed luma        picture sample array recPicture_(L) as inputs, and filtIdx[x][y]        and transposeIdx[x][y] with x, y=0 . . . CtbSizeY−1 as outputs.        For the derivation of the filtered reconstructed luma samples        alfPicture_(L) [x][y], each reconstructed luma sample inside the        current luma codingtree block recPicture_(L) [x][y] is filtered        as follows with x, y=0 . . . CtbSizeY−1:    -   The array of luma filter coefficients f[j] and the array of luma        clipping values c[j] corresponding to the filter specified by        filtIdx[x][y] is derived as follows with j=0 . . . 11:        -   If AlfCtbFiltSetIdxY[xCtb>>Log2Ctb Size][yCtb>>Log2CtbSize]            is less than 16, the following applies:

$\begin{matrix}{i = {{Alf}{CtbFilt}{Set}{{{IdxY}\left\lbrack {{xCtb}\operatorname{>>}{{Log}2{Ctb}{Size}}} \right\rbrack}\left\lbrack {{y{Ctb}}\operatorname{>>}{{Log}2{Ctb}{Size}}} \right\rbrack}}} & \left( {8 - 1187} \right)\end{matrix}$ $\begin{matrix}{\left. {{f\lbrack j\rbrack} = {{Alf}{Fix}{{FiltCoeff}\left\lbrack {{Alf}{Class}{To}{Filt}{{Map}\lbrack i\rbrack}{{{filtIdx}\lbrack x\rbrack}\lbrack y\rbrack}} \right\rbrack}}} \right\rbrack\lbrack j\rbrack} & \left( {8 - 1188} \right)\end{matrix}$ $\begin{matrix}{{c\lbrack j\rbrack} = 2^{BitDepthY}} & \left( {8 - 1189} \right)\end{matrix}$

-   -   -   Otherwise            (AlfCtbFiltSetIdxY[xCtb>>Log2CtbSize][yCtb>>Log2CtbSize] is            greater than or equal to 16, the following applies:

$\begin{matrix}{i = {{slice\_ alf}{\_ aps}{\_ id}{{\_ luma}\left\lbrack {{{Alf}{CtbFilt}{Set}{{{IdxY}\left\lbrack {{xCtb}\operatorname{>>}{{Log}2{Ctb}{Size}}} \right\rbrack}\left\lbrack {{yCtb}\operatorname{>>}{{Log}2{Ctb}{Size}}} \right\rbrack}} - 16} \right\rbrack}}} & \left( {8 - 1190} \right)\end{matrix}$ $\begin{matrix}{{f\lbrack j\rbrack} = {{{{AlfCoeff}_{L}\lbrack i\rbrack}\left\lbrack {{filt}{{{Idx}\lbrack x\rbrack}\lbrack y\rbrack}} \right\rbrack}\lbrack j\rbrack}} & \left( {8 - 1191} \right)\end{matrix}$ $\begin{matrix}{{c\lbrack j\rbrack} = {{Alf}{{{{Clip}_{L}\lbrack i\rbrack}\left\lbrack {{filt}{{{Idx}\lbrack x\rbrack}\lbrack y\rbrack}} \right\rbrack}\lbrack j\rbrack}}} & \left( {8 - 1192} \right)\end{matrix}$

-   -   The luma filter coefficients and clipping values index idx are        derived depending on transposeIdx[x][y] as follows:        -   If transposeIndex[x][y] is equal to 1, the following            applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {9,4,{10},8,1,5,11,7,3,0,2,6} \right\}} & \left( {8 - 1193} \right)\end{matrix}$

-   -   -   Otherwise, if transposeIndex[x][y] is equal to 2, the            following applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {0,3,2,1,8,7,6,5,4,9,10,11} \right\}} & \left( {8 - 1194} \right)\end{matrix}$

-   -   -   Otherwise, if transposeIndex[x][y] is equal to 3, the            following applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {9,8,{10},4,3,7,11,5,1,0,2,6} \right\}} & \left( {8 - 1195} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{{id{x{\lbrack\rbrack}}} = \left\{ {0,1,2,3,4,5,6,7,8,9,10,11} \right\}} & \left( {8 - 1196} \right)\end{matrix}$

-   -   The locations (h_(x+i), v_(y+j)) for each of the corresponding        luma samples (x,y) inside the given array recPicture of luma        samples with i, j=−3 . . . 3 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1            and xCtb+x−PpsVirtualBoundariesPosX[n] is greater than or            equal to 0 and less than 3 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{PosX}\lbrack n\rbrack}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1197} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1            and PpsVirtualBoundariesPosX[n]−xCtb−x is greater than 0 and            less than 4 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{PosX}\lbrack n\rbrack}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1198} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1199} \right)\end{matrix}$

-   -   -   [[When loop_filter_across_sub_pic_enabled_flag[SubPicIdx]            for the subpicture containing the luma sample at location            (h_(g), v_(y)) is equal to 0, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{SubPic}{Left}{Boundary}{Pos}},{{SubPic}{Right}{Boundary}{Pos}},h_{x + i}} \right)}} & \left( {8 - 1184} \right)\end{matrix}$

-   -   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1            and yCtb+y−PpsVirtualBoundariesPosY[n] is greater than or            equal to 0 and less than 3 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1200} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1            and PpsVirtualBoundariesPosY[n]−yCtb−y is greater than 0 and            less than 4 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1201} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8 - 1202} \right)\end{matrix}$

-   -   -   [[When loop_filter_across_sub_pic_enabled_flag[SubPicIdx]            for the subpicture containing the luma sample at location            (h_(x), v_(y)) is equal to 0, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{SubPic}{Top}{Boundary}{Pos}},{{SubPicBot}{Boundary}{}{Pos}},v_{y + j}} \right)}} & \left( {8 - 1184} \right)\end{matrix}$

-   -   The variable apply VirtualBoundary is derived as follows:        -   If one or m ore of the following conditions are true, apply            VirtualBoundary is set equal to 0:            -   The bottom boundary of the current coding tree block is                the bottom boundary of the picture.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the brick and                loop_filter_across_bricks_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the slice and                loop_filter_across_slices_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the subpicture and                loop_filter_across_sub_pic_enabled_flag[SubPicIdx] for                the subpicture containing the luma sample at location                (h_(x), v_(y)) is equal to 0.            -   The bottom boundary of the current coding tree block is                one of the bottom virtual boundaries of the picture and                pps_loop_filter_across_virtual_boundaries_disabled_flag                is equal to 1.        -   Otherwise, applyVirtualBoundary is set equal to 1.]]

    -   The reconstructed sample offsets r1, r2 and r3 are specified in        Table 8-24 according to the        luma sample position y,

    -   

    -   The variable curr is derived as follows:

$\begin{matrix}{{curr} = {{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y}} \right\rbrack}}} & \left( {8 - 1203} \right)\end{matrix}$ Thevariablesumisderivedasfollows: $\begin{matrix}{{sum} = {{{f\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y + {r3}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 0\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y - {r3}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {c1}},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 1\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {c1}},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 2\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {c1}},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 3\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {c1}},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {c2}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 4\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {c2}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {c1}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 5\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {c1}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 6\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {c1}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 7\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {c1}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {c2}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 8\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {c2}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {c3}},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 9\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {c3}},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {c2}},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 10\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {c2}},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack}*\left( {{{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x + {c1}},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack}},{c\left\lbrack {{idx}\lbrack 11\rbrack} \right\rbrack},{{{rec}{{Picture}_{L}\left\lbrack {h_{x - {c1}},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)}}} & \left( {8 - 1204} \right)\end{matrix}$ $\begin{matrix}{{sum} = {{curr} + \left( {\left( {{sum} + 64} \right)\operatorname{>>}7} \right)}} & \left( {8 - 1205} \right)\end{matrix}$

-   -   The modified filtered reconstructed luma picture sample        alfPicture_(L)[xCtb+x][yCtb+y] is derived as follows:        -   If pcm_loop_filter_disabled_flag and            pcm_flag[xCtb+x][yCtb+y] are both equal to 1, the following            applies:

$\begin{matrix}{{{alf}{{{Picture}_{L}\left\lbrack {{xCtb} + x} \right\rbrack}\left\lbrack {{yCtb} + y} \right\rbrack}} = {{rec}{{Picture}_{L}\left\lbrack {h_{x},v_{y}} \right\rbrack}}} & \left( {8 - 1206} \right)\end{matrix}$

-   -   -   Otherwise (pcm_loop_filter_disabled_flag is equal to 0 or            pcm_flag[x][y] is equal 0), the following applies:

$\begin{matrix}{{{alf}{{{Picture}_{L}\left\lbrack {{xCtb} + x} \right\rbrack}\left\lbrack {{yCtb} + y} \right\rbrack}} = {{Clip}3\left( {0,{\left( {1{\operatorname{<<}{Bit}}{Depth}_{Y}} \right) - 1},{sum}} \right)}} & \left( {8 - 1207} \right)\end{matrix}$

TABLE 8-24 Specification of r1, r2, and r3 according to the[[horizontal]]

  luma sample position y,

   [[and applyVirtual Boundary condition r1 r2 r3 (y = = CtbSizeY − 5 ∥y = = CtbSizeY − 4 ) && (applyVirtualBoundary = = 1 ) 0 0 0 (y = =CtbSizeY − 6 ∥ y = = CtbSizeY − 3 ) && (applyVirtualBoundary = = 1 ) 1 11 (y = = CtbSizeY − 7 ∥ y = = CtbSizeY − 2 ) && (applyVirtualBoundary == 1 ) 1 2 2 otherwise 1 2 3 ]]

   

   

   

 

  

   

   

   

 

  

   

   

   

 

  

   

   

   

 

 

  

   

   

   

 

   

   

   

 

TABLE 8-25 Specification of c1, c2, and c3 according to the horizontalluma sample position x, clipLeftPos and clipRightPos  

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

   

 

8.8.5.3 Derivation Process for ALF Transpose and Filterindex for LumaSamples

Inputs of this process are:

-   -   a luma location (xCtb,yCtb) specifying the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture,    -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process.        Outputs of this process are    -   the classification filter index array filtIdx[x][y] with x, y=0        . . . CtbSizeY−1,    -   the transpose index array transposeIdx[x][y] with x, y=0 . . .        CtbSizeY−1.        The locations (bx+v_(y)+) for each of the corresponding luma        samples (x,y) inside the given array recPicture of luma samples        with i, j=−2 . . . 5 are derived as follows:    -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1        and xCtb+x−PpsVirtualBoundariesPosX[n] is greater than or equal        to 0 and less than 2 for any n=0 . . .        pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{PosX}\lbrack n\rbrack}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1208} \right)\end{matrix}$

-   -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1        and PpsVirtualBoundariesPosX[n]−xCtb−x is greater than 0 and        less than 6 for any n=0 . . . pps_num_ver_virtual_boundaries−1,        the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{PosX}\lbrack n\rbrack}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1209} \right)\end{matrix}$

-   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8 - 1210} \right)\end{matrix}$

-   -   [[When loop_filter_across_subpic_enabled_flag[SubPicIdx] for the        subpicture containing the luma sample at location (h_(g), v_(y))        is equal to 0, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{Sub}{PicLeftBoundary}{Pos}},{{Sub}{PicRightBoundary}{Pos}},h_{x + i}} \right)}} & \left. \left. \left( {8‐1184} \right) \right\rbrack \right\rbrack\end{matrix}$

-   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1        and yCtb+y−PpsVirtualBoundariesPosY[n] is greater than or equal        to 0 and less than 2 for any n=0 . . .        pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{PpsVirtua}{{lBoundariesPosY}\lbrack n\rbrack}},{{pic\_ heigt}_{-}{in\_ luma}\_ 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1211} \right)\end{matrix}$

-   -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1        and PpsVirtualBoundariesPosY[n]−yCtb−y is greater than 0 and        less than 6 for any n=0 . . . pps_num_hor_virtual_boundaries−1,        the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{PpsVirtua}{{lBoundariesPosY}\lbrack n\rbrack}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1212} \right)\end{matrix}$

-   -   Otherwise, the following applies:        -   [[If y Ctb+CtbSizeY is greater than or equal to            pic_height_in_luma_samples, the following applies:]]

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ heigt}{\_ in}{\_ luma}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1213} \right)\end{matrix}$

-   -   -   [[Otherwise, if y is less than CtbSizeY−4, the following            applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{yCtb} + {CtbSizeY} - 5},{{yCtb} + y + j}} \right)}} & \left( {8‐1214} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{yCtb} + {CtbSizeY} - 4},{{{pic\_ heigt}{\_ in}{\_ luna}{\_ samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1215} \right)\end{matrix}$

-   -   -   When loop_filter_across_sub_pic_enabled_flag[SubPicIdx] for            the subpicture containing the luma sample at location            (h_(x),v_(y)) is equal to 0, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{SubPicTopBoundaryPos},{SubPicBotBoundaryPos},v_{y + j}} \right)}} & \left( {8‐1184} \right)\end{matrix}$

-   -   

    -   

    -   

    -   

    -           The classification filter index array filtIdx and the transpose        index array transposeIdx are derived by the following ordered        steps:

    -   1. The variables filtH[x][y], filtV[x][y], filtD0[x][y] and        filtD1[x][y] with x,y=−2 . . . CtbSizeY+1 ale derived as        follows:        -   If both x and y are even numbers or both x and y are uneven            numbers, the following applies:

$\begin{matrix}{{{filt}{{H\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}}\  \right\rbrack}{\operatorname{<<}1}} \right) - {{recPicture}\left\lbrack {h_{x - 1},v_{y}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x + 1},v_{y}}\  \right\rbrack}} \right)}} & \left( {8‐1216} \right)\end{matrix}$ $\begin{matrix}{{{filt}{{V\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}}\  \right\rbrack}{\operatorname{<<}1}} \right) - {{recPicture}\left\lbrack {h_{x},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x},v_{y + 1}}\  \right\rbrack}} \right)}} & \left( {8‐1217} \right)\end{matrix}$ $\begin{matrix}{{{filt}D{{0\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}}\  \right\rbrack}{\operatorname{<<}1}} \right) - {{recPicture}\left\lbrack {h_{x - 1},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x + 1},v_{y + 1}}\  \right\rbrack}} \right)}} & \left( {8‐1218} \right)\end{matrix}$ $\begin{matrix}{{{filt}D{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}}\  \right\rbrack}{\operatorname{<<}1}} \right) - {{recPicture}\left\lbrack {h_{x + 1},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x - 1},v_{y + 1}}\  \right\rbrack}} \right)}} & \left( {8‐1219} \right)\end{matrix}$

-   -   -   Otherwise, filtH[x][y], filtV[x][y], filtD0[x][y] and            filtD1[x][y] are set equal to 0.

    -   2. [[The variables minY, maxY and ac are derived as follows:

    -   If (y<<2) is equal to (CtbSizeY−8) and (yCtb+CtbSizeY) is less        than pic_height_in_luma_samples−1, minY is set equal to 2, maxY        is set equal to 3 and ac is set equal to 96.

    -   Otherwise, if (y<<2) is equal to (CtbSizeY−4) and        (yCtb+CtbSizeY) is less than pic_height_in_luma_samples−1, minY        is set equal to 0, maxY is set equal to 5 and ac is set equal to        96.]]

    -   3.        -   -   -   

            -   -   

            -   -   

            -   Otherwise, minY is set equal to −2 and maxY is set equal                to 5.

        -   -   -   

            -   -   

            -   

        -   

TABLE 8-26 Specification of ac according to minX, minY, maxX, maxY  

   

   

   

   

   

   

   

   

   

   

   

   

 

-   -   -   [[The variables sumH[x][y], sumV[x][y], sumD0[x][y],            sumD1[x][y] and sumOfHV[x][y] with x, y=0 . . .            (CtbSizeY−1) >>2 are derived as follows:]]

$\begin{matrix}{{{{sum}{{H\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filt}{{H\left\lbrack {h_{{({x{\operatorname{<<}2}})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y{\operatorname{<<}2}})} + j}\  - {yCtb}} \right\rbrack}{with}i}}} = \underline{\min X\ldots\max X}}}{\left\lbrack \left\lbrack {{- 2}\ldots 5} \right\rbrack \right\rbrack,{j = {m{in}Y\ldots\max Y}}}} & \left( {8‐1220} \right)\end{matrix}$ $\begin{matrix}{{{{sum}{{V\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filt}{{V\left\lbrack {h_{{({x{\operatorname{<<}2}})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y{\operatorname{<<}2}})} + j}\  - {yCtb}} \right\rbrack}{with}i}}} = \underline{\min X\ldots\max X}}}{\left\lbrack \left\lbrack {{- 2}\ldots 5} \right\rbrack \right\rbrack,{j = {m{in}Y\ldots\max Y}}}} & \left( {8‐1221} \right)\end{matrix}$ $\begin{matrix}{{{{sum}D{{0\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filt}D{{0\left\lbrack {h_{{({x{\operatorname{<<}2}})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y{\operatorname{<<}2}})} + j}\  - {yCtb}} \right\rbrack}{with}i}}} = \underline{\min X\ldots\max X}}}{\left\lbrack \left\lbrack {{- 2}\ldots 5} \right\rbrack \right\rbrack,{j = {m{in}Y\ldots\max Y}}}} & \left( {8‐1222} \right)\end{matrix}$ $\begin{matrix}{{{{sum}D{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{\sum_{i}{\sum_{j}{{filt}D{{1\left\lbrack {h_{{({x{\operatorname{<<}2}})} + i} - {xCtb}} \right\rbrack}\left\lbrack {v_{{({y{\operatorname{<<}2}})} + j}\  - {yCtb}} \right\rbrack}{with}i}}} = \underline{\min X\ldots\max X}}}{\left\lbrack \left\lbrack {{- 2}\ldots 5} \right\rbrack \right\rbrack,{j = {m{in}Y\ldots\max Y}}}} & \left( {8‐1223} \right)\end{matrix}$ $\begin{matrix}{{{sum}{{{OfHV}\lbrack x\rbrack}\lbrack y\rbrack}} = {{{sum}{{H\lbrack x\rbrack}\lbrack y\rbrack}} + {{sum}{{V\lbrack x\rbrack}\lbrack y\rbrack}}}} & \left( {8‐1224} \right)\end{matrix}$

-   -   4. The variables dir1 [x][y], dir2[x][y] and dirS[x][y] with        x,y=0 . . . CtbSizeY−1 are derived as follows:        -   The variables hv1,hv0 and dirHV are derived as follows:            -   If sumV[x>>2][y>>2] is greater than sumH[x>>2][y>>2],                the following applies:

$\begin{matrix}{{{hv}1} = {{sum}{{V\left\lbrack {x\operatorname{>>}2} \right\rbrack}\left\lbrack {y\operatorname{>>}2} \right\rbrack}}} & \left( {8‐1225} \right)\end{matrix}$ $\begin{matrix}{{{hv}0} = {{sum}{{H\left\lbrack {x\operatorname{>>}2} \right\rbrack}\left\lbrack {y\operatorname{>>}2} \right\rbrack}}} & \left( {8‐1226} \right)\end{matrix}$ $\begin{matrix}{{{dir}{HV}} = 1} & \left( {8‐1227} \right)\end{matrix}$

-   -   -   -   Otherwise, the following applies:

$\begin{matrix}{{{hv}1} = {{sum}{{H\left\lbrack {x\operatorname{>>}2} \right\rbrack}\left\lbrack {y\operatorname{>>}2} \right\rbrack}}} & \left( {8‐1228} \right)\end{matrix}$ $\begin{matrix}{{{hv}0} = {{sum}{{V\left\lbrack {x\operatorname{>>}2} \right\rbrack}\left\lbrack {y\operatorname{>>}2} \right\rbrack}}} & \left( {8‐1229} \right)\end{matrix}$ $\begin{matrix}{{{dir}{HV}} = 3} & \left( {8‐1230} \right)\end{matrix}$

-   -   -   The variables d1, d0 and dirD are derived as follows:            -   If sumD0[x>>2][y>>2] is greater than sumD1 [x>>2][y>>2],                the following applies:

$\begin{matrix}{{d1} = {{sum}D{{0\left\lbrack {x\operatorname{>>}2} \right\rbrack}\left\lbrack {y\operatorname{>>}2} \right\rbrack}}} & \left( {8‐1231} \right)\end{matrix}$ $\begin{matrix}{{d0} = {{sum}D{{1\left\lbrack {x\operatorname{>>}2} \right\rbrack}\left\lbrack {y\operatorname{>>}2} \right\rbrack}}} & \left( {8‐1232} \right)\end{matrix}$ $\begin{matrix}{{dirD} = 0} & \left( {8‐1233} \right)\end{matrix}$

-   -   -   -   Otherwise, the following applies:

$\begin{matrix}{{d1} = {{sum}D{{1\left\lbrack {x\operatorname{>>}2} \right\rbrack}\left\lbrack {y\operatorname{>>}2} \right\rbrack}}} & \left( {8‐1234} \right)\end{matrix}$ $\begin{matrix}{{d0} = {{sum}D{{0\left\lbrack {x\operatorname{>>}2} \right\rbrack}\left\lbrack {y\operatorname{>>}2} \right\rbrack}}} & \left( {8‐1235} \right)\end{matrix}$ $\begin{matrix}{{dirD} = 2} & \left( {8‐1236} \right)\end{matrix}$

-   -   -   The variables hvd1, hvd0, are derived as follows:

$\begin{matrix}{{{hvd}1} = {{\left( {{d1*{hv}0} > {{hv}1*\ d0}} \right)?d}1:{hv}1}} & \left( {8‐1237} \right)\end{matrix}$ $\begin{matrix}{{{hvd}0} = {{\left( {{d1*{hv}0} > {{hv}1*\ d0}} \right)?d}0:{hv}0}} & \left( {8‐1238} \right)\end{matrix}$

-   -   -   The variables dirS[x][y], dir1 [x][y] and dir2[x][y] derived            as follows:

$\begin{matrix}{{{dir}{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{\left( {{d1*{hv}0} > {{hv}1*\ d0}} \right)?{dirD}}:{dir}{HV}}} & \left( {8‐1239} \right)\end{matrix}$ $\begin{matrix}{{{dir}{{2\lbrack x\rbrack}\lbrack y\rbrack}} = {{\left( {{d1*{hv}0} > {{hv}1*\ d0}} \right)?{dir}}{HV}:{dir}D}} & \left( {8‐1240} \right)\end{matrix}$ $\begin{matrix}{{{dir}{{S\lbrack x\rbrack}\lbrack y\rbrack}} = {{\left( {{{hvd}1} > {2*{hv}\ d0}} \right)?1}:\left( {{\left( {{{hvd}1*2} > {9*{hvd}0}} \right)?2}:0} \right)}} & \left( {8‐1241} \right)\end{matrix}$

-   -   5. The variable avgVar[x][y] with x, y=0 . . . CtbSizeY−1 is        derived as follows:

$\begin{matrix}{{{var}{{Tab}{\lbrack\rbrack}}} = \left\{ {0,1,2,2,2,2,2,3,3,3,3,3,3,3,3,4} \right\}} & \left( {8 - 1242} \right)\end{matrix}$ $\begin{matrix}{{{avg}{{{Var}\lbrack x\rbrack}\lbrack y\rbrack}} = {{var}{{Tab}\left\lbrack {{Clip}3\left( {0,{15},\ {\left( {{sum}{Of}{{{HV}\left\lbrack {x\operatorname{>>}2} \right\rbrack}\left\lbrack {y\operatorname{>>}2} \right\rbrack}*{ac}} \right)\operatorname{>>}\left( {3 + {{Bit}{}{Depth}_{Y}}} \right)}} \right.} \right\rbrack}}} & \left( {8 - 1243} \right)\end{matrix}$

-   -   6. The classification filter index array filtIdx[x][y] and the        transpose index array transposeIdx[x][y] with x=y=0 . . .        CtbSizeY−1 are derived as follows:

transposeTable[] = {0, 1, 0, 2, 2, 3, 1, 3}transposeIdx[x][y] = transposeTable[dir1[x][y] * 2 + (dir2[x][y]>> 1)]filtIdx[x][y] = avgVar[x][y]

When dirS[x][y] is not equal 0, filtIdx[x][y] is modified as follows:

$\begin{matrix}{{{filt}{{{Idx}\lbrack x\rbrack}\lbrack y\rbrack}}+={\left( {\left( {\left( {{dir}{{1\lbrack x\rbrack}\lbrack y\rbrack}\& 0 \times 1} \right){\operatorname{<<}1}} \right) + {{{dirS}\lbrack x\rbrack}\lbrack y\rbrack}} \right)*5}} & \left( {8 - 1244} \right)\end{matrix}$

8.8.5.4 Coding Tree Block Filtering Process for Chroma Samples

Inputs of this process are:

-   -   a reconstructed chroma picture sample array recPicture prior to        the adaptive loop filtering process,    -   a filtered reconstructed chroma picture sample array alfPicture,    -   a chroma location (xCtbC, yCtbC) specifying the top-left sample        of the current chroma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        chroma picture sample array alfPicture.        The width a nd height of the current chroma coding tree block        ctbWidthC and ctbHeightC is derived as follows:

$\begin{matrix}{{{ctb}{Width}C} = {{Ctb}{Size}Y/{Sub}{Width}C}} & \left( {8 - 1245} \right)\end{matrix}$ $\begin{matrix}{{{ctb}{Height}C} = {{Ctb}{Size}Y/{Sub}{Height}C}} & \left( {8 - 1246} \right)\end{matrix}$

For the derivation of the filtered reconstructed chroma samplesalfPicture[x][y], each reconstructed chroma sample inside the currentchroma coding tree block recPicture[x][y] is filtered as follows withx=0 . . . ctbWidthC−1, y=0 . . . ctbHeightC−1:

-   -   The locations (h_(x+i), v_(y)+) for each of the corresponding        chroma samples (x,y) inside the given array recPicture of chroma        samples with i, j=−2 . . . 2 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1            and xCtbC+x PpsVirtualBoundariesPosX[n]/SubWidthC is greater            than or equal to 0 and less than 2 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{PosX}\lbrack n\rbrack}/{Sub}{Width}C},} \right.}} & \left( {8 - 1247} \right)\end{matrix}$ pic_width_in_luma_samples/SubWidthC − 1, xCtbC + x + i)

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1            and PpsVirtualBoundariesPosX[n]/SubWidthC−xCtbC−x is greater            than 0 and less than 3 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{PosX}\lbrack n\rbrack}/{Sub}{Width}C} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1248} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{Sub}{Width}C} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8 - 1249} \right)\end{matrix}$

-   -   -   [[When loop_filter_across_sub_pic_enabled_flag[SubPicIdx]            for the subpicture containing the luma sample at location            (h_(g), v_(y)) is equal to 0, the following applies:

h_(x + i) = Clip3(SubPicLeftBoundaryPos/SubWidthC, SubPicRightBoundaryPos/SubWidthC, h_(x + i))(8 − 1184)]]

-   -   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1            and yCtbC+y−PpsVirtualBoundariesPosY[n]/SubHeightC is            greater than or equal to 0 and less than 2 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}/{Sub}{Height}C},} \right.}} & \left( {8 - 1250} \right)\end{matrix}$ pic_height_in_luma_samples/SubHeightC − 1, yCtbC + y + j)

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1            and PpsVirtualBoundariesPosY[n]/SubHeightC−yCtbC−y is            greater than 0 and less than 3 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{Pps}{Virtual}{Boundaries}{{PosY}\lbrack n\rbrack}/{Sub}{Height}C} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1251} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{Sub}{Height}C} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8 - 1252} \right)\end{matrix}$

-   -   -   [[When loop_filter_across_sub_pic_enabled_flag[SubPicIdx]            for the subpicture containing the luma sample at location            (h_(x), v_(y)) is equal to 0, the following applies:

v_(y + j) = Clip3(SubPicTopBoundaryPos/SubWidthC, SubPicBotBoundaryPos/SubWidthC, v_(y + j))(8 − 1184)

-   -   The variable apply VirtualBoundary is derived as follows:        -   If one or more of the following conditions are true, apply            VirtualBoundary is set equal to 0:            -   The bottom boundary of the current codingtree block is                the bottom boundary of the picture.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the brick and                loop_filter_across_bricks_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the slice and                loop_filter_across_slices_enabled_flag is equal to 0.            -   The bottom boundary of the current coding tree block is                the bottom boundary of the subpicture and                loop_filter_across_sub_pic_enabled_flag[SubPicIdx] for                the subpicture containing the luma sample at location                (h_(x), v_(y)) is equal to 0.            -   The bottom boundary of the current codingtree block is                one of the bottom virtual boundaries of the picture and                pps_loop_filter_across_virtual_boundaries_disabled_flag                is equal to 1.        -   Otherwise, applyVirtualBoundary is set equal to 1.]]

    -   -   

        -   

        -   

        -   

    -   The reconstructed sample offsets r1 and r2 are specified in        Table 8-27 according to the [[horizontalluma]]        sample position y,        [[and apply VirtualBoundary]].

    -   

    -   The variable curr is derived as follows:

$\begin{matrix}{{curr} = {{rec}{{Picture}{}\left\lbrack {h_{x},v_{y}}\  \right\rbrack}}} & \left( {8 - 1253} \right)\end{matrix}$

-   -   The array of chromafilter coefficients f[j] and the array of        chroma clipping valuesc[j] is derived as follows with j=0 . . .        5:

$\begin{matrix}{{f\lbrack j\rbrack} = {{Alf}{{{Coeff}_{C}\left\lbrack {{slice\_ alf}{\_ aps}{\_ id}{\_ chroma}} \right\rbrack}\lbrack j\rbrack}}} & \left( {8 - 1254} \right)\end{matrix}$ $\begin{matrix}{{c\lbrack j\rbrack} = {{Alf}{{{Clip}_{C}\left\lbrack {{slice\_ alf}{\_ aps}{\_ id}{\_ chroma}} \right\rbrack}\lbrack j\rbrack}}} & \left( {8 - 1255} \right)\end{matrix}$

-   -   The variable sum is derived as follows:

$\begin{matrix}{{sum} = {{{f\lbrack 0\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 0\rbrack}},{c\lbrack 0\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x},v_{y + {r2}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 0\rbrack}},{c\lbrack 0\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x},v_{y - {r2}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack 1 \right\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 1\rbrack}},{c\lbrack 1\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x + {c1}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 1\rbrack}},{c\lbrack 1\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x - {c1}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\lbrack 2\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 2\rbrack}},{c\lbrack 2\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 2\rbrack}},{c\lbrack 2\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {\left\lbrack 1 \right\rbrack*{f\lbrack 3\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 3\rbrack}},{c\lbrack 3\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x - {c1}},v_{y + {r1}}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 3\rbrack}},{c\lbrack 3\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x + {c1}},v_{y - {r1}}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack 4 \right\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 4\rbrack}},{c\lbrack 4\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x + {c2}},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 4\rbrack}},{c\lbrack 4\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x - {c2}},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)} + {{f\left\lbrack 5 \right\rbrack}*\left( {{{Clip}3\left( {{- {c\lbrack 5\rbrack}},{c\lbrack 5\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x + {c1}},v_{y}} \right\rbrack}} - {curr}}} \right)} + {{Clip}3\left( {{- {c\lbrack 5\rbrack}},{c\lbrack 5\rbrack},{{{rec}{{Picture}\left\lbrack {h_{x - {c1}},v_{y}} \right\rbrack}} - {curr}}} \right)}} \right)}}} & \left( {8 - 1256} \right)\end{matrix}$ $\begin{matrix}{{{sum} = {{curr} + \left( {{sum} + 64} \right)}}\operatorname{>>}7} & \left( {8 - 1257} \right)\end{matrix}$

-   -   The modified filtered reconstructed chroma picture sample        alfPicture[xCtbC+x][yCtbC+y] is derived as follows:        -   If pcm_loop_filter_disabled_flag and            pcm_flag[(xCtbC+x)*SubWidthC][(yCtbC+y)*SubHeightC] are both            equal to 1, the following applies:

$\begin{matrix}{{{{alfPicture}\left\lbrack {{xCtbC} + x} \right\rbrack}\left\lbrack {{yCtbC} + y} \right\rbrack} = {{recPicture}_{L}\left\lbrack {h_{x},v_{y}} \right\rbrack}} & \left( {8‐1258} \right)\end{matrix}$

-   -   -   Otherwise (pcm_loop_filter_disabled_flag is equal to 0 or            pcm_flag[x][y] is equal 0), the following applies:

$\begin{matrix}{{{{alfPicture}\left\lbrack {{xCtbC} + x} \right\rbrack}\left\lbrack {{yCtbC} + y} \right\rbrack} = {{{Clip}3}\left( {0,{\left( {1 \ll {BitDepth}_{C}} \right) - 1},{sum}} \right)}} & \left( {8‐1259} \right)\end{matrix}$

TABLE 8-27 Specification of r1 and r2 according to the [[horizontalluma]]  

  sample position y,  

  [[and applyVirtual Boundary condition r1 r2 (y = = ctbHeightC − 2 ∥ y= = ctbHeightC − 3 ) && ( applyVirtualBoundary = = 1 ) 0 0 (y = =ctbHeightC − 1 ∥ y = = ctbHeightC − 4 ) && ( applyVirtualBoundary = = 1) 1 1 otherwise 1 2 ]]  

   

   

   

  

   

   

   

  

   

   

   

   

  

   

   

   

   

   

 

TABLE 8-28 Specification of c1 and c2 according to horionztal chromasample position x, clipLeftPos and clipRightPos  

   

   

   

   

   

   

   

   

   

   

   

   

   

 

-   -   

    -   

    -   

    -   

    -   

    -   

    -   

    -   -   

    -   -   

        -   

        -   

    -   

    -   

    -   

    -   -   

        -   

        -   

    -   -   

    -   -   

        -   

        -   

    -   -   

    -   -   

        -   

        -   

The specific value −128 used in above embodiment may be replaced byother values, such as −K wherein for example, K is greater than or nosmaller than the number of lines shifted from a CTU bottom boundary(e.g, K=−5).

Alternatively, one flag may be used to mark whether each sample need tobe handled in a different way if it is located at video unit boundaries.

5.10 Embodiment #10 8.8.5.2 Coding Tree Block Filtering Process For LumaSamples

Inputs of this process are:

-   -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process,    -   a filtered reconstructed luma picture sample array        alfPicture_(L),    -   a luma location (xCtb,yCtb) specifying the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture.        Output of this process is the modified filtered reconstructed        luma picture sample array alfPicture_(L).        The derivation process for filter index clause 8.8.5.3 is        invoked with the location (xCtb,yCtb) and the reconstructed luma        picture sample array recPicture_(L) as inputs, and filtIdx[x][y]        and transposeIdx[x][y] with x, y=0 . . . CtbSizeY−1 as outputs.        For the derivation of the filtered reconstructed luma samples        alfPicture_(L)[x][y], each reconstructed luma sample inside the        current luma codingtree block recPicture_(L) [x][y] is filtered        as follows with x, y=0 . . . CtbSizeY−1:        . . .    -   The locations (h_(x+i), v_(y+j)) for each of the corresponding        luma samples (x,y) inside the given array recPicture of luma        samples with i, j=−3 . . . 3 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1, and PpsVirtualBoundariesPosX[n] % CtbSizeY is            not equal to 0, and xCtb+x−PpsVirtualBoundariesPosX[n] is            greater than or equal to 0 and less than 3 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{{Clip}3}\left( {{{PpsVirtualBoundariesPosX}\lbrack n\rbrack},{{{pic}\_{width}\_{in}\_{luma}\_{samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8‐1229} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1, and PpsVirtualBoundariesPosX[n] % CtbSizeY is            not equal to 0, and PpsVirtualBoundariesPosX[n]−xCtb−x is            greater than 0 and less than 4 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{PpsVirtualBoundariesPosX}\lbrack n\rbrack} - 1},{{xCtb} + x + i}} \right)}} & \left( {8‐1230} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{{Clip}3}\left( {0,{{{pic}\_{width}\_{in}\_{luma}\_{samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8‐1231} \right)\end{matrix}$

-   -   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1, and PpsVirtualBoundariesPosY[n] % CtbSizeY is            not equal to 0, a nd y Ctb+y−PpsVirtualBoundariesPosY[n] is            greater than or equal to 0 and less than 3 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{V_{y + j} = {{{Clip}3}\left( {{{PpsVirtualBoundariesPosY}\lbrack n\rbrack},{{{pic}\_{width}\_{in}\_{luma}\_{samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1232} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1, and PpsVirtualBoundariesPosY[n] % CtbSizeY is            not equal to 0, and PpsVirtualBoundariesPosY[n]−yCtb−y is            greater than 0 and less than 4 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{V_{y + j} = {{Clip}3\left( {0,{{{PpsVirtualBoundariesPosY}\lbrack n\rbrack} - 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1233} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{V_{y + j} = {{{Clip}3}\left( {0,{{{pic}\_{height}\_{in}\_{luma}\_{samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1234} \right)\end{matrix}$

-   -   The variables clipLeftPos, clipRightPos, clip TopPos,        clipBottomPos,        are derived by invoking the ALF boundary position derivation        process as specified in clause 8.8.5.5 with (xCtb, yCtb) and        (x,y) as inputs.

    -   -   

        -   

    -   -   

        -   

    -   -   

        -   

    -   -   

        -   

    -   The vertical sample position offsets y1, y2 and y3 are specified        in Table 8-20 according to the vertical luma sample position y,        clipLeftPos and clipRightPos.

    -   The horizontal sample position offsets x1, x2 and x3 are        specified in Table 8-21 according to the horizontal luma sample        position x, clipLeftPos and clipRightPos.        . . .

8.8.5.3 Derivation Process for ALF Transpose and Filter Index for LumaSamples

Inputs of this process are:

-   -   a luma location (xCtb,yCtb) specify in g the top-left sample of        the current luma coding tree block relative to the top left        sample of the current picture,    -   a reconstructed luma picture sample array recPicture_(L) prior        to the adaptive loop filtering process.        Outputs of this process are    -   the classification filter index array filtIdx[x][y] with x, y=0        . . . CtbSizeY−1,    -   the transpose index array transposeIdx[x][y] with x, y=0 . . .        CtbSizeY−1.        The locations (h_(x+i), v_(y+j)) for each of the corresponding        luma samples (x,y) inside the given array recPicture of luma        samples with i, j=−2 . . . 5 are derived as follows:    -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1, and PpsVirtualBoundariesPosX[n]% CtbSizeY is not        equal to 0, and xCtb+x−PpsVirtualBoundariesPosX[n] is greater        than or equal to 0 and less than 2 for any n=0 . . .        pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{{Clip}3}\left( {{{PpsVirtualBoundariesPosX}\lbrack n\rbrack},{{{pic}\_{width}\_{in}\_{luma}\_{samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8‐1239} \right)\end{matrix}$

-   -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1, and PpsVirtualBoundariesPosX[n]% CtbSizeY is not equal to        0, and PpsVirtualBoundariesPosX[n]−xCtb−x is greater than 0 and        less than 6 for any n=0 . . . pps_num_ver_virtual_boundaries−1,        the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{PpsVirtualBoundariesPosX}\lbrack n\rbrack} - 1},{{xCtb} + x + i}} \right)}} & \left( {8‐1240} \right)\end{matrix}$

-   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{{Clip}3}\left( {0,{{{pic}\_{width}\_{in}\_{luma}\_{samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8‐1241} \right)\end{matrix}$

-   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1, and PpsVirtualBoundariesPosY[n]% CtbSizeY is not        equal to 0, and yCtb+y−PpsVirtualBoundariesPosY[n] is greater        than or equal to 0 and less than 2 for any n=0 . . .        pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{V_{y + j} = {{{Clip}3}\left( {{{PpsVirtualBoundariesPosY}\lbrack n\rbrack},{{{pic}\_{height}\_{in}\_{luma}\_{samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1242} \right)\end{matrix}$

-   -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1, and PpsVirtualBoundariesPosY[n]% CtbSizeY is not equal to        0, and PpsVirtualBoundariesPosY[n]−yCtb−y is greater than 0 and        less than 6 for any n=0 . . . pps_num_hor_virtual_boundaries−1,        the following applies:

$\begin{matrix}{V_{y + j} = {{{Clip}3}\left( {0,{{{PpsVirtualBoundariesPosY}\lbrack n\rbrack}1},{{yCtb} + y + j}} \right)}} & \left( {8‐1243} \right)\end{matrix}$

-   -   Otherwise, the following applies:

$\begin{matrix}{V_{y + j} = {{{Clip}3}\left( {0,{{{pic}\_{height}\_{in}\_{luma}\_{samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1244} \right)\end{matrix}$

-   -   The variables clipLeftPos, clipRightPos, clipTopPos,        clipBottomPos        are derived by invoking the ALF boundary position derivation        process as specified in clause 8.8.5.5 with (xCtb,yCtb) and        (x,y) as inputs.    -   If clipTopPos is not equal to −128, the following applies:

$\begin{matrix}{V_{y + j} = {{{Clip}3}\left( {{clipTopPos},{{{pic}\_{height}\_{in}\_{luma}\_{samples}} - 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1245} \right)\end{matrix}$

-   -   If clipBottomPos is not equal to −128, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{clipBottomPos} - 1},{{yCtb} + y + j}} \right)}} & \left( {8‐1246} \right)\end{matrix}$

-   -   If clipLeftPos is not equal to −128, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{clipLeftPos},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}} - 1},{{xCtb} + x + i}} \right)}} & \left( {8‐1247} \right)\end{matrix}$

If clipRightPos is not equal to −128, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{clipRightPos} - 1},{{xCtb} + x + i}} \right)}} & \left( {8‐1248} \right)\end{matrix}$

-   -   -   

        -   

    -   -   

        -   

    -   -   

        -   

    -   -   

        -               The classification filter index array filtIdx and the            transpose index array transposeIdx are derived by the            following ordered steps:

-   1. The variables filtH[x][y], filtV[x][y], filtD0[x][y] and    filtD1[x][y] with x, y=−2 . . . CtbSizeY+1 are derived as follows:    -   If both x and y are even numbers or both x and y are not even        numbers, the following applies:

$\begin{matrix}{{{filtH}{\lbrack x\rbrack\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x - 1},v_{y}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x + 1},v_{y}} \right\rbrack}} \right)}} & \left( {8‐1249} \right)\end{matrix}$ $\begin{matrix}{{{{filtV}\lbrack x\rbrack}\lbrack y\rbrack} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8‐1250} \right)\end{matrix}$ $\begin{matrix}{{{filtD}{{0\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x - 1},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x + 1},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8‐1251} \right)\end{matrix}$ $\begin{matrix}{{{filtD}{{1\lbrack x\rbrack}\lbrack y\rbrack}} = {{Abs}\left( {\left( {{{recPicture}\left\lbrack {h_{x},v_{y}} \right\rbrack} \ll 1} \right) - {{recPicture}\left\lbrack {h_{x + 1},v_{y - 1}} \right\rbrack} - {{recPicture}\left\lbrack {h_{x - 1},v_{y + 1}} \right\rbrack}} \right)}} & \left( {8‐1252} \right)\end{matrix}$

-   -   Otherwise, filtH[x][y], filtV[x][y], filtD0[x][y] and        filtD1[x][y] are set equal to 0.        . . .

8.8.5.3 Coding Tree Block Filtering Process for Chroma Samples

Inputs of this process are:

-   -   a reconstructed chroma picture sample array recPicture prior to        the adaptive loop filtering process,    -   a filtered reconstructed chroma picture sample array alfPicture,    -   a chroma location (xCtbC, yCtbC) specifying the top-left sample        of the current chroma coding tree block relative to the top left        sample of the current picture,    -   an alternative chroma filter index altIdx.        Output of this process is the modified filtered reconstructed        chroma picture sample array alfPicture.        The width a nd height of the current chroma coding tree block        ctbWidthC and ctbHeightC is derived as follows:

$\begin{matrix}{{ctbWidthC} = {{CtbSizeY}/{SubWidthC}}} & \left( {8‐1278} \right)\end{matrix}$ $\begin{matrix}{{ctbHeightC} = {{CtbSizeY}/{SubHeightC}}} & \left( {8‐1279} \right)\end{matrix}$

For the derivation of the filtered reconstructed chroma samplesalfPicture[x][y], each reconstructed chroma sample inside the currentchroma coding tree block recPicture[x][y] is filtered as follows withx=0 . . . ctbWidthC−1, y=0 . . . ctbHeightC−1:

-   -   The locations (h_(x+i), v_(y+j)) for each of the corresponding        chroma samples (x,y) inside the given array recPicture of chroma        samples with i, j=−2 . . . 2 are derived as follows:        -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1, and PpsVirtualBoundariesPosX[n]% CtbSizeY is            not equal to 0 and            xCtbC+x−PpsVirtualBoundariesPosX[n]/SubWidthC is greater            than or equal to 0 and less than 2 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {{{{PpsVirtualBoundariesPosX}\lbrack n\rbrack}/{SubWidthC}},{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8‐1280} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1, and PpsVirtualBoundariesPosX[n]% CtbSizeY is not            equal to 0 and PpsVirtualBoundariesPosX[n]/SubWidthC−xCtbC−x            is greater than 0 and less than 3 for any n=0 . . .            pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{{PpsVirtualBoundariesPosX}\lbrack n\rbrack}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8‐1281} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{h_{x + i} = {{Clip}3\left( {0,{{{pic\_ width}{\_ in}{\_ luma}{\_ samples}/{SubWidthC}} - 1},{{xCtbC} + x + i}} \right)}} & \left( {8‐1282} \right)\end{matrix}$

-   -   -   If pps_loop_filter_across_virtual_boundaries_disabled_flag            is equal to 1, and PpsVirtualBoundariesPosY[n]% CtbSizeY is            not equal to 0 and            yCtbC+y−PpsVirtualBoundariesPosY[n]/SubHeightC is greater            than or equal to 0 and less than 2 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {{{{PpsVirtualBoundariesPosY}\lbrack n\rbrack}/{SubHeightC}},{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{SubHeightC}} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8‐1283} \right)\end{matrix}$

-   -   -   Otherwise, if            pps_loop_filter_across_virtual_boundaries_disabled_flag is            equal to 1, and PpsVirtualBoundariesPosY[n]% CtbSizeY is not            equal to 0 and            PpsVirtualBoundariesPosY[n]/SubHeightC−yCtbC−y is greater            than 0 and less than 3 for any n=0 . . .            pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{{PpsVirtualBoundariesPosY}\lbrack n\rbrack}/{SubHeightC}} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8‐1284} \right)\end{matrix}$

-   -   -   Otherwise, the following applies:

$\begin{matrix}{v_{y + j} = {{Clip}3\left( {0,{{{pic\_ height}{\_ in}{\_ luma}{\_ samples}/{SubHeightC}} - 1},{{yCtbC} + y + j}} \right)}} & \left( {8‐1285} \right)\end{matrix}$

-   -   -   The variables clipLeftPos, clipRightPos, clipTopPos,            clipBottomPos            are derived by invoking the ALF boundary position derivation            process as specified in clause 8.8.5.5 with            (xCtbC*SubWidthC,yCtbC*SubHeightC) and (x*SubWidthC,            y*SubHeightC) as inputs.

    -   -   

        -   

    -   -   

        -   

    -   -   

        -   

    -   -   

        -   

        -   The variable clipLeftPos is set equal to            clipLeftPos/SubWidthC.

        -   The variable clipRightPos is set equal to            clipRightPos/SubWidthC.

        -   The variable clip TopPos is set equal to            clipTopPos/SubHeightC.

        -   The variable clipBottomPos is set equal to            clipBottomPos/SubHeightC.

8.5.5.5 ALF Boundary Position Derivation Process

Inputs of this process are:

-   -   a luma location (xCtb, yCtb) specifying the top-left sample of        the current luma codingtree block relative to the top left        sample of the current picture,

    -   a luma location (x,y) specifying the current sample relative to        the top-left sample of the current luma codingtree block.        Output of this process are:

    -   the left vertical boundary position clipLeftPos,

    -   the right vertical boundary position clipRightPos,

    -   the above horizontal boundary position clipTopPos,

    -   the below horizontal boundary position clipBottomPos.

    -   

    -   

    -   

    -           The variables clipLeftPos, clipRightPos, clipTopPos and        clipBottomPos are set equal to −128.        The variable clipTopPos is modified as follows:

    -   If the bottom boundary of the current coding tree block is not        the bottom boundary of the picture and y (CtbSizeY−4) is greater        than or equal to 0, the variable clipTopPos is set equal to        yCtb+CtbSizeY−4.

    -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1, and PpsVirtualBoundariesPosY[n] % CtbSizeY is equal to 0,        and yCtb+y−PpsVirtualBoundariesPosY[n] is greater than or equal        to 0 and less than 3 for any n=0 . . .        pps_num_hor_virtual_boundaries−1, the following applies:

$\begin{matrix}{{clipTopPos} = {{PpsVirtualBoundariesPosY}\lbrack n\rbrack}} & \left( {8‐1292} \right)\end{matrix}$

-   -   Otherwise, if y is less than 3, and the top boundary of the        current codingtree block is not the top boundary of the picture,        and one or more of the following conditions are true, the        variable clipTopPos is set equal to yCtb:    -   If the top boundary of the current coding tree block is the top        boundary of the brick, and        loop_filter_across_bricks_enabled_flag is equal to 0.    -   If the top boundary of the current coding tree block is the top        boundary of the slice, and        loop_filter_across_slices_enabled_flag is equal to 0.    -   If the top boundary of the current coding tree block is the top        boundary of the subpicture, and        loop_filter_across_subpic_enabled_flag[SubPicIdx] is equal to 0.        The variable clipBottomPos is modified as follows:    -   If the bottom boundary of the current coding tree block is not        the bottom boundary of the picture and CtbSizeY−4−y is greater        than 0 and is less than 4, the variable clipBottomPos is set        equal to yCtb+CtbSizeY−4.    -   Otherwise, if        pps_loop_filter_across_virtual_boundaries_disabled_flag is equal        to 1, PpsVirtualBoundariesPosY[n] % CtbSizeY is equal to 0,        PpsVirtualBoundariesPosY[n] is not equal to        pic_height_in_luma_samples−1 or 0, and        PpsVirtualBoundariesPosY[n]−yCtb−y is greater than 0 and less        than 4 for any n=0 . . . pps_num_hor_virtual_boundaries−1, the        following applies:

$\begin{matrix}{{clipBottomPos} = {{PpsVirtualBoundariesPosY}\lbrack n\rbrack}} & \left( {8‐1293} \right)\end{matrix}$

-   -   Otherwise, if CtbSizeY−y is less than 4, and the bottom boundary        of the current coding tree block is not the bottom boundary of        the picture, and one or more of the following conditions are        true, the variable clipBottomPos is set equal to yCtb+CtbSizeY:    -   If the bottom boundary of the current coding tree block is the        bottom boundary of the brick, and        loop_filter_across_bricks_enabled_flag is equal to 0.    -   If the bottom boundary of the current coding tree block is the        bottom boundary of the slice, and        loop_filter_across_slices_enabled_flag is equal to 0.    -   If the bottom boundary of the current coding tree block is the        bottom boundary of the subpicture, and        loop_filter_across_subpic_enabled_flag[SubPicIdx] is equal to 0.        The variable clipLeftPos is modified as follows:    -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1, and PpsVirtualBoundariesPosX[n] % CtbSizeY is equal        to 0, and xCtb+x−PpsVirtualBoundariesPosX[n] is greater than or        equal to 0 and less than 3 for any n=0 . . .        pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{{clipLeftPos} = {{PpsVirtualBoundariesPosX}\lbrack n\rbrack}} & \left( {8‐1294} \right)\end{matrix}$

-   -   Otherwise, if x is less than 3, the left boundary of the current        coding tree block is not the left boundary of the picture and        one or more of the following conditions are true, the variable        clipLeftPos is set equal to xCtb:    -   If the left boundary of the current coding tree block is the        left boundary of the brick, and        loop_filter_across_bricks_enabled_flag is equal to 0.    -   If the left boundary of the current coding tree block is the        left boundary of the slice, and        loop_filter_across_slices_enabled_flag is equal to 0.    -   If the left boundary of the current coding tree block is the        left boundary of the subpicture, and        loop_filter_across_subpic_enabled_flag[SubPicIdx] is equal to 0.        The variable clipRightPos is modified as follows:    -   If pps_loop_filter_across_virtual_boundaries_disabled_flag is        equal to 1, and PpsVirtualBoundariesPosX[n] % CtbSizeY is equal        to 0, and PpsVirtualBoundariesPosX[n]−xCtb−x is greater than 0        and less than 4 for any n=0 . . .        pps_num_ver_virtual_boundaries−1, the following applies:

$\begin{matrix}{{clipRightPos} = {{PpsVirtualBoundariesPosX}\lbrack n\rbrack}} & \left( {8‐1295} \right)\end{matrix}$

-   -   Otherwise, if CtbSizeY−x is less than 4, and the right boundary        of the current coding tree block is not the right boundary of        the picture, and one or more of the following conditions are        true, the variable clipRightPos is set equal to xCtb+CtbSizeY:

    -   If the right boundary of the current coding tree block is the        right boundary of the brick, and        loop_filter_across_bricks_enabled_flag is equal to 0.

    -   If the right boundary of the current coding tree block is the        right boundary of the slice, and        loop_filter_across_slices_enabled_flag is equal to 0.

    -   if the right boundary of the current coding tree block is the        right boundary of the subpicture, and        loop_filter_across_subpic_enabled_flag[SubPicIdx] is equal to 0.

    -   

    -   -   

        -   

        -   

    -   

    -   

    -   

    -   

    -   

    -   

    -   

    -   

    -   

    -   

    -   

FIG. 22 is a block diagram of a video processing apparatus 2200. Theapparatus 2200 may be used to implement one or more of the methodsdescribed herein. The apparatus 2200 may be embodied in a smartphone,tablet, computer, Internet of Things (IoT) receiver, and so on. Theapparatus 2200 may include one or more processors 2202, one or morememories 2204 and video processing hardware 2206. The processor(s) 2202may be configured to implement one or more methods described in thepresent document. The memory (memories) 2204 may be used for storingdata and code used for implementing the methods and techniques describedherein. The video processing hardware 2206 may be used to implement, inhardware circuitry, some techniques described in the present document.In some embodiments, the video processing hardware 2206 may be internalor partially internal to the processor 2202 (e.g., graphics processorunit).

In some embodiments, the video coding methods may be implemented usingan apparatus that is implemented on a hardware platform as describedwith respect to FIG. 22 .

FIG. 23 is a flowchart of an example method 2300 of video processing.The method includes determining (2302), for a conversion between acurrent video block of a video and a bitstream representation of thecurrent video block, one or more interpolation filters to use during theconversion, wherein the one or more interpolation filters are frommultiple interpolation filters for the video and performing (2304) theconversion using the one or more interpolation filters.

Various solutions and embodiments described in the present document arefurther described using a list of solutions.

Section 4, item 1 provides additional examples of the followingsolutions.

1. A method of video processing, comprising: performing a conversionbetween video blocks of a video picture and a bitstream representationthereof, wherein the video blocks are processed using logical groupingsof coding tree blocks, wherein the coding tree blocks are processedbased on whether a bottom boundary of a bottom coding tree block isoutside a bottom boundary of the video picture.

2. The method of solution 1, wherein the processing the coding treeblock includes performing an adaptive loop filtering of sample values ofthe coding tree block by using samples within the coding tree block.

3. The method of solution 1, wherein the processing the coding treeblock includes performing an adaptive loop filtering of sample values ofthe coding tree block by disabling splitting the coding tree block intotwo parts according to virtual boundaries.

Section 4, item 2 provides additional examples of the followingsolutions.

4. A method of video processing, comprising: determining, based on acondition of a coding tree block of a current video block, a usagestatus of virtual samples during an in-loop filtering; and performing aconversion between the video block and a bitstream representation of thevideo block consistent with the usage status of virtual samples.

5. The method of solution 4, wherein, a logical true value of the usagestatus indicates that the current video block is split at least to twoparts by a virtual boundary and filtering samples in one part isdisallowed to utilize the information from another part.

6. The method of solution 4, wherein, a logical true value of the usagestatus indicates virtual samples are used during the in-loop filtering,and wherein the in-loop filtering is performed using modified values ofreconstructed samples of the current video block.

7. The method of solution 4, wherein a logical false value of the usagestatus indicates that filtering samples in the block is allowed toutilize the information in the same block.

8. The method of solution 4, wherein, a logical true value of the usagestatus indicates the in-loop filtering is performed on reconstructedsamples of the current video block without further modifying thereconstructed samples.

9. The method of any of solutions 4-8, wherein the condition specifiesto set the usage status to the logical false value due to the codingtree block having a specific size.

10. The method of any of solutions 4-8, wherein the condition specifiesto set the usage status to the logical false value due to the codingtree block having a size greater than a specific size.

11. The method of any of solutions 4-8tree block having a size less thana specific size.

Section 4, item 3 provides additional examples of the followingsolutions.

12. The method of solution 5, wherein the condition depends on whether abottom boundary of the current video block is a bottom boundary of avideo unit that is smaller than the video picture or the bottom boundaryof the current video block is a virtual boundary.

13. The method of solution 12, wherein the condition depends on whethera bottom boundary of the current video block is a bottom boundary of aslice or tile or brick boundary.

14. The method of solution 12, wherein the condition specifies to setthe usage status to the logical true value when the bottom boundary ofthe current videoblock is a bottom boundary of a slice or tile or brickboundary.

15. The method of solution 4-12, wherein the condition specifies to setthe usage status to the logical false value when the bottom boundary ofthe current video block is a bottom boundary of a picture boundary oroutside the bottom boundary of a picture boundary.

Section 4, item 4 provides additional examples of the followingsolutions.

16. A method of video processing, comprising: determining, during aconversion between a video picture that is logically grouped into one ormore video slices or video bricks, and a bitstream representation of thevideo picture, to disable a use of samples in another slice or brick inthe adaptive loop filter process; and performing the conversionconsistent with the determining.

Section 4, item 5 provides additional examples of the followingsolutions.

17. A method of video processing, comprising: determining, during aconversion between a current video block of a video picture and abitstream representation of the current video block, that the currentvideo block includes samples located at a boundary of a video unit ofthe video picture; and performing the conversion based on thedetermining, wherein the performing the conversion includes generatingvirtual samples for an in-loop filtering process using a unified methodthat is same for all boundary types in the video picture.

18. The method of solution 17, wherein the video unit is a slice or tileor 360-degree video.

19. The method of solution 17, wherein the in-loop filtering includesadaptive loop filtering.

20. The method of any of solutions 17-19, wherein the unified method isa two-side padding method.

21. The method of any of solutions 17-20, wherein the unified method iswhen accessing samples below a first line is disallowed and padding isutilized to generate virtual samples for those below the first line,then accessing samples above a second line is also set to be disallowedand padding is utilized to generate virtual samples for those above thesecond line.

22. The method of any of solutions 17-20, wherein the unified method iswhen accessing samples above a first line is disallowed and padding isutilized to generate virtual samples for those above the first line,then accessing samples below a second line is also set to be disallowedand padding is utilized to generate virtual samples for those below thesecond line.

23. The method of any of solutions 21-22, wherein the distance betweenthe first line and a current line where the current sample to befiltered is located and distance between the second line and the firstline is equal.

Section 4, item 6 provides additional examples of the followingsolutions.

24. A method of video processing, comprising: determining to apply,during a conversion between a current video block of a video picture anda bitstream representation thereof, one of multiple adaptive loop filter(ALF) sample selection methods available for the video picture duringthe conversion; and performing the conversion by applying the one ofmultiple ALF sample selection methods.

25. The method of solution 24, wherein the multiple ALF sample selectionmethods include a first method in which samples are selected before anin-loop filter is applied to the current video block during theconversion and a second method in which samples are selected after anin-loop filter is applied to the current video block during theconversion.

Section 4, item 7 provides additional examples of the followingsolutions.

26. A method of video processing, comprising: performing, based on aboundary rule, an in-loop filtering operation over samples of a currentvideo block of a video picture during a conversion between the currentvideoblock and a bitstream representation of a current video block;wherein the boundary rule disables using samples that cross a virtualpipeline data unit (VPDU) of the video picture, and performing theconversion using a result of the in-loop filtering operation.

27. The method of solution 26, wherein the VPDU corresponds to a regionof the video picture having a fixed size.

28. The method of any of solutions 26-27, wherein the boundary rulefurther specifies to use virtual samples for the in-loop filtering inplace of disabled samples.

29. The method of solution 28, wherein the virtual samples are generatedby padding.

Section 4, item 8 provides additional examples of the followingsolutions.

30. A method of video processing, comprising: performing, based on aboundary rule, an in-loop filtering operation over samples of a currentvideo block of a video picture during a conversion between the currentvideoblock and a bitstream representation of a current video block;wherein the boundary rule specifies to use, for locations of the currentvideo block across a video unit boundary, samples that are generatedwithout using padding; and performing the conversion using a result ofthe in-loop filtering operation.

31. The method of solution 30, wherein the samples are generated using atwo-side padding technique.

32. The method of solution 30, wherein the in-loop filtering operationcomprises using a same virtual sample generation technique forsymmetrically located samples during the in-loop filtering operation.

33. The method of any of solutions 30-32, wherein the in-loop filteringoperation over samples of the current video block includes performingreshaping of the samples of the current video block prior to applyingthe in-loop filtering.

Section 4, item 9 provides additional examples of the followingsolutions.

34. A method of video processing, comprising: performing, based on aboundary rule, an in-loop filtering operation over samples of a currentvideo block of a video picture during a conversion between the currentvideoblock and a bitstream representation of a current video block;wherein the boundary rule specifies selecting, for the in-loop filteringoperation, a filter having dimensions such that samples of current videoblock used during the in-loop filtering do not cross a boundary of avideo unit of the video picture; and performing the conversion using aresult of the in-loop filtering operation.

Section 4, item 10 provides additional examples of the followingsolutions.

35. A method of video processing, comprising: performing, based on aboundary rule, an in-loop filtering operation over samples of a currentvideo block of a video picture during a conversion between the currentvideoblock and a bitstream representation of a current video block;wherein the boundary rule specifies selecting, for the in-loop filteringoperation, clipping parameters or filter coefficients based on whetheror not padded samples are needed for the in-loop filtering; andperforming the conversion using a result of the in-loop filteringoperation.

36. The method of solution 35, wherein the clipping parameters or filtercoefficients are included in the bitstream representation.

Section 4, item 11 provides additional examples of the followingsolutions.

37. A method of video processing, comprising: performing, based on aboundary rule, an in-loop filtering operation over samples of a currentvideo block of a video picture during a conversion between the currentvideoblock and a bitstream representation of a current video block;wherein the boundary rule depends on a color component identity of thecurrent video block; and performing the conversion using a result of thein-loop filtering operation.

38. The method of solution 37, wherein the boundary rule is differentfor luma and/or different color components.

39. The method of any of solutions 1-38, wherein the conversion includesencoding the current video block into the bitstream representation.

40. The method of any of solutions 1-38, wherein the conversion includesdecoding the bitstream representation to generate sample values of thecurrent video block.

41. A video encoding apparatus comprising a processor configured toimplement a method recited in any one or more of solutions 1-38.

42. A video decoding apparatus comprising a processor configured toimplement a method recited in any one or more of solutions 1-38.

43. A computer-readable medium having code stored thereon, the code,upon execution by a processor, causing the processor to implement amethod recited in any one or more of solutions 1-38.

FIG. 31 is a block diagram showing an example video processing system3100in which various techniques disclosed herein may be implemented.Various implementations may include some or all of the components of thesystem 3100. The system 3100 may include input 3102 for receivingvideocontent. The video content may be received in a raw or uncompressedformat, e.g, 8 or 10 bit multi-component pixel values, or may be in acompressed or encoded format. The input 3102 may represent a networkinterface, a peripheral bus interface, or a storage interface. Examplesof network interface include wired interfaces such as Ethernet, passiveoptical network (PON), etc. and wireless interfaces such as Wi-Fi orcellular interfaces.

The system 3100 may include a coding component 3104 that may implementthe various coding or encoding methods described in the presentdocument. The coding component 3104 may reduce the average bitrate ofvideo from the input 3102 to the output of the coding component 3104 toproduce a coded representation of the video. The coding techniques aretherefore sometimes called video compression or video transcodingtechniques. The output of the coding component 3104 may be eitherstored, or transmitted via a communication connected, as represented bythe component 3106. The stored or communicated bitstream (or coded)representation of the video received at the input 3102 may be used bythe component 3108 for generating pixel values or displayable video thatis sent to a display interface 3110. The process of generatinguser-viewable video from the bitstream representation is sometimescalled video decompression. Furthermore, while certain video processingoperations are referred to as “coding” operations or tools, it will beappreciated that the coding tools or operations are used at an encoderand corresponding decoding tools or operations that reverse the resultsof the coding will be performed by a decoder.

Examples of a peripheral bus interface or a display interface mayinclude universal serial bus (USB) or high definition multimediainterface (HDMI) or Displayport, and so on. Examples of storageinterfaces include SATA (serial advanced technology attachment), PCI,IDE interface, and the like. The techniques described in the presentdocument may be embodied in various electronic devices such as mobilephones, laptops, smartphones or other devices that are capable ofperforming digital data processing and/or video display.

FIG. 32 is a flowchart representation of a method 3200 for videoprocessing in accordance with the present technology. The method 3200includes, at operation 3210, determining, for a conversion between acurrent block of a video and a bitstream representation of the video,that one or more samples of the video outside the current block areunavailable for a coding process of the conversion. The coding processcomprises an adaptive loop filter (ALF) coding process. The method 3200also includes, at operation 3220, performing, based on the determining,the conversion by using padded samples for the one or more samples ofthe video. The padded samples are generated by checking for availabilityof samples in an order.

In some embodiments, the current block comprises a coding unit, apicture unit, or a coding tree unit. In some embodiments, the one ormore samples outside the current block that are unavailable comprise asample located in a first neighboring block that is located above and tothe left of the current block. The order specifies that (1) samples in asecond neighboring block that is above the current block are checkedfirst, (2) in case the samples in the second neighboring block areunavailable, samples in a third neighboring block that is positioned tothe left of the current block are checked next, and (3) in case thesamples in the third neighboring block are also unavailable, a top-leftsample of the current block is used to generate a padded sample.

In some embodiments, the one or more samples outside the current blockthat are unavailable comprise a sample located in a first neighboringblock that is located below and to the right of the current block. Theorder specifies that (1) samples in a second neighboring block that isbelow the current block are checked first, (2) in case the samples inthe second neighboring block are unavailable, samples in a thirdneighboring block that is positioned to the right of the current blockare checked next, and (3) in case the samples in the third neighboringblock are also unavailable, a bottom-right sample of the current blockis used generate a padded sample.

In some embodiments, the one or more samples outside the current blockthat are unavailable comprise a sample located in a first neighboringblock that is located above and to the right of the current block. Theorder specifies that: (1) samples in a second neighboring block that isabove the current block are checked first, (2) in case the samples inthe second neighboring block are unavailable, samples in a thirdneighboring block that is positioned to the right of the current blockare checked next, and (3) in case the sample in the third neighboringblock are also unavailable, a top-right sample of the current block isused generate a padded sample.

In some embodiments, the one or more samples outside the current blockthat are unavailable comprise a sample located in a first neighboringblock that is located below and to the left of the current block. Theorder specifies that: (1) samples in a second neighboring block that isbelow the current block are checked first, (2) in case the samples inthe second neighboring block are unavailable, samples in a thirdneighboring block that is positioned to the left of the current blockare checked next, and (3) in case the sample in the third neighboringblock are also unavailable, a top-left sample of the current block isused to generate a padded sample.

In some embodiments, the one or more samples outside the current blockthat are unavailable comprise a sample located in a first neighboringblock that is located above and to the left of the current block. Theorder specifies that: (1) samples in a second neighboring block that ispositioned to the left of the current block are checked first, (2) incase the samples in the second neighboring block are unavailable,samples in a third neighboring block that is above the current block arechecked next, and (3) in case the sample in the third neighboring blockare also unavailable, a top-left sample of the current block is used forto generate a padded sample.

In some embodiments, the one or more samples outside the current blockthat are unavailable comprise a sample located in a first neighboringblock that is located above and to the right of the current block. Theorder specifies that (1) samples in a second neighboring block that ispositioned to the right of the current block are checked first, (2) incase the samples in the second neighboring block are unavailable,samples in a third neighboring block above the right of the currentblock are checked next, and (3) in case the sample in the thirdneighboring block are also unavailable, a top-right sample of thecurrent block is used to generate a padded sample.

In some embodiments, the one or more samples outside the current blockthat are unavailable comprise a sample located in a first neighboringblock that is located below and to the left of the current block. Theorder specifies that (1) samples in a second neighboring block that ispositioned to the left of the current block are checked first, (2) incase the samples in the second neighboring block unavailable, samples ina third neighboring block below the left of the current block arechecked next, and (3) in case the sample in the third neighboring blockare also unavailable, a top-left sample of the current block is used togenerate a padded sample.

In some embodiments, the one or more samples outside the current blockthat are unavailable comprise a sample located in a first neighboringblock that is located below and to the right of the current block. Theorder specifies that: (1) samples in a second neighboring block that ispositioned to the right of the currentblock are checked first, (2) incase the samples in the second neighboring block are unavailable,samples in a third neighboring block below the right of the currentblock are checked next, and (3) in case the sample in the thirdneighboring block are also unavailable, a bottom-right sample of thecurrent block is used to generate a padded sample.

In some embodiments, the order specifies that (1) vertical availablesamples are checked first, and (2) horizontal available samples areoptionally checked next. In some embodiments, the order specifies that(1) horizontal available samples are checked first, and (2) verticalavailable samples are optionally checked next. In some embodiments,samples in each neighboring block of the current block are checked in anorder. In some embodiments, only one sample is checked in eachneighboring block of current block.

In some embodiments, a current sample in the current block is used inthe ALF coding process in case no available sample is found to generatea padded sample. In some embodiments, for an unavailable sample in aneighboring block that is located (1) above and to the left of thecurrent block, (2) above and to the right of the current block, (3)below and to the right of the current block, or (4) below and to theright of the current block, the sample is padded using one or moresamples in the current block. In some embodiments, a top-left sample ofthe current block is used to pad a sample in a neighboring block that islocated above and to the left of the current block. In some embodiments,a top-right sample of the current block is used to pad a sample in aneighboring block that is located above and to the right of the currentblock. In some embodiments, a below-left sample of the current block isused to pad a sample in a neighboring block that is located below and tothe left of the current block. In some embodiments, a below-right sampleof the current block is used to pad a sample in a neighboring block thatis located below and to the right of the current block. In someembodiments, the coding process further comprises another filteringcoding process that accesses the one or more samples outside the currentblock.

FIG. 33 is a flowchart representation of a method 3300 for videoprocessing in accordance with the present technology. The method 3300includes, at operation 3310, making a first determination, for aconversion between a current block of a video and a bitstreamrepresentation of the video, about whether a sample in a neighboringblock of the current block is in a same video region as the currentblock. The neighboring block is located (1) above and to the left of thecurrent block, (2) above and to the right of the current block, (3)below and to the left of the current block, or (4) below and to theright of the current block. The method 3300 includes, at operation 3320,using the first determination to make a second determination aboutapplicability of a coding tool that uses samples outside the currentblock to the conversion of the current block. The coding tool comprisesan adaptive loop filter (ALF) tool that comprises an ALF classificationprocess and/or an ALF filtering process. The method 3300 includes, atoperation 3330, performing the conversion according to the firstdetermination and the second determination.

In some embodiments, the current block comprises a coding unit, apicture unit, or a coding tree unit. In some embodiments, a video regioncomprises a slice, a brick a tile, or a sub-picture. In someembodiments, a sample is considered to be unavailable for the codingtool in case (1) the sample and a current sample of the current blockare in different video regions, and (2) accessing samples acrossdifferent video regions of the video is disabled for the coding tool. Insome embodiments, a syntax element is signaled in the codedrepresentation to indicate whether accessing samples across differentvideo regions of the video is disabled. In some embodiments, the methodfurther includes applying a padding process in response to the samplebeing unavailable to derive a padded sample for the coding tool.

In some embodiments, a top-left sample of the current block isrepresented as (x0, y0), and a sample (x0−offsetX0, y0−offsetY0) in theneighboring block that is located above and to the left of the currentblock is checked, offsetX0 and offsetY0 being integers. In someembodiments, (offsetX0, offsetY0) comprises (1, 1), (2, 1), or (1, 2).

In some embodiments, a top-left sample of the current block isrepresented as (x0, y0), and a sample (x0+offsetX1, y0−offsetY1) in theneighboring block that is located above and to the right of the currentblock is checked, offsetX1 and offsetY1 being integers. In someembodiments, (offsetX1, offsetY1) comprises (BlockWidth, 1),(BlockWidth+1, 1), or (BlockWidth, 2), where BlockWidth is a width ofthe current block.

In some embodiments, a top-left sample of the current block isrepresented as (x0, y0), and a sample (x0−offsetX2, y0+offsetY0) in theneighboring block that is located below and to the left of the currentblock is checked, offsetX2 and offsetY2 being integers. In someembodiments, (offsetX2, offsetY2) comprises (1, BlockHeight), (2,BlockHeight), or (1, BlockHeight+1), where BlockHeight is a height ofthe current block.

In some embodiments, a top-left sample of the current block isrepresented as (x0, y0), and a sample (x0+offsetX3, y0+offsetY3) in theneighboring block that is located above and to the right of the currentblock is checked, offsetX3 and offsetY3 being integers. In someembodiments, (offsetX3, offsetY3) comprises (BlockWidth, BlockHeight),(BlockWidth+1, BlockHeight), or (BlockWidth, BlockHeight+1), whereBlockWidth is a width of the currentblock and BlockHeight is a height ofthe current block.

In some embodiments, offsetXk or offsetYk are determined based on awidth or a height of the current block, wherein k=0, 1, or 3. In someembodiments, the coding tool further comprises another filtering codingtool.

In some embodiments, applicability of one or more of the methods to thecurrent block is determined based on a characteristic of the video. Insome embodiments, the characteristic of the video comprises informationsignaled in a decoder parameter set, a slice parameter set, a videoparameter set, a picture parameter set, an adaptation parameter set, apicture header, a slice header, a tile group header, a largest codingunit (LCU), a coding unit, a LCU row, a group of LCUs, a transform unit,a picture unit, or a video coding unit in the coded representation. Insome embodiments, the characteristic of the video comprises a positionof a coding unit, a picture unit, a transform unit, a block, or a videocoding unit within the video. In some embodiments, the characteristic ofthe video comprises a characteristic of a current block or a neighboringblock of the current block. In some embodiments, the characteristic of acurrent block or neighboring blocks of the current block comprises adimension of the current block or a dimension of the neighboring blockof the current block. In some embodiments, the characteristic of acurrent block or neighboring blocks of the current block comprises ashape of the current block or a shape of the neighboring block of thecurrent block. In some embodiments, the characteristic of the videocomprises an indication of a color format of the video. In someembodiments, the characteristic of the video comprises a coding treestructure applicable to the video. In some embodiments, thecharacteristic of the video comprises a slice type, a tile group type,or a picture type of the video. In some embodiments, the characteristicof the video comprises color component of the video. In someembodiments, the characteristic of the video comprises a temporal layeridentifier of the video. In some embodiments, the characteristic of thevideo comprises a profile, a level, or a tier of a video standard.

In some embodiments, the conversion includes encoding the video into thebitstream representation. In some embodiments, the conversion includesdecoding the bitstream representation into the video.

FIG. 34 is a block diagram that illustrates an example video codingsystem 100 that may utilize the techniques of this disclosure.

As shown in FIG. 34 , video coding system 100 may include a sourcedevice 110 and a destination device 120. Source device 110 generatesencoded video data which may be referred to as a video encoding device.Destination device 120 may decode the encoded video data generated bysource device 110 which may be referred to as a video decoding device.

Source device 110 may include a video source 112, a video encoder 114,and an input/output (I/O) interface 116.

Video source 112 may include a source such as a video capture device, aninterface to receive video data from a video content provider, and/or acomputer graphics system for generating video data, or a combination ofsuch sources. The video data may comprise one or more pictures. Videoencoder 114 encodes the video data from video source 112 to generate abitstream. The bitstream may include a sequence of bits that form acoded representation of the video data. The bitstream may include codedpictures and associated data. The coded picture is a codedrepresentation of a picture. The associated data may include sequenceparameter sets, picture parameter sets, and other syntax structures. I/Ointerface 116 may include a modulator/demodulator (modem) and/or atransmitter. The encoded video data may be transmitted directly todestination device 120 via I/O interface 116 through network 130 a. Theencoded video data may also be stored onto a storage medium/server 130 bfor access by destination device 120.

Destination device 120 may include an I/O interface 126, a video decoder124, and a display device 122.

I/O interface 126 may include a receiver and/or a modem. I/O interface126 may acquire encoded video data from the source device 110 or thestorage medium/server 130 b. Video decoder 124 may decode the encodedvideo data. Display device 122 may display the decoded video data to auser. Display device 122 may be integrated with the destination device120, or may be external to destination device 120 which be configured tointerface with an external display device.

Video encoder 114 and video decoder 124 may operate according to a videocompression standard, such as the High Efficiency Video Coding (HEVC)standard, Versatile Video Coding (VVC) standard and other current and/orfurther standards.

FIG. 35 is a block diagram illustrating an example of video encoder 200,which may be video encoder 114 in the system 100 illustrated in FIG. 34.

Video encoder 200 may be configured to perform any or all of thetechniques of this disclosure. In the example of FIG. 9 , video encoder200 includes a plurality of functional components. The techniquesdescribed in this disclosure may be shared among the various componentsof video encoder 200. In some examples, a processor may be configured toperform any or all of the techniques described in this disclosure.

The functional components of video encoder 200 may include a partitionunit 201, a predication unit 202 which may include a mode select unit203, a motion estimation unit 204, a motion compensation unit 205 and anintra prediction unit 206, a residual generation unit 207, a transformunit 208, a quantization unit 209, an inverse quantization unit 210, aninverse transform unit 211, a reconstruction unit 212, a buffer 213, andan entropy encoding unit 214.

In other examples, video encoder 200 may include more, fewer, ordifferent functional components. In an example, predication unit 202 mayinclude an intra block copy (IBC) unit. The IBC unit may performpredication in an IBC mode in which at least one reference picture is apicture where the current video block is located.

Furthermore, some components, such as motion estimation unit 204 andmotion compensation unit 205 may be highly integrated, but arerepresented in the example of FIG. 5 separately for purposes ofexplanation.

Partition unit 201 may partition a picture into one or more videoblocks. Video encoder 200 and video decoder 300 may support variousvideo block sizes.

Mode select unit 203 may select one of the coding modes, intra or inter,e.g., based on error results, and provide the resulting intra- orinter-coded block to a residual generation unit 207 to generate residualblock data and to a reconstruction unit 212 to reconstruct the encodedblock for use as a reference picture. In some example, Mode select unit203 may select a combination of intra and inter predication (CIIP) modein which the predication is based on an inter predication signal and anintra predication signal. Mode select unit 203 may also select aresolution for a motion vector (e.g., a sub-pixel or integer pixelprecision) for the block in the case of inter-predication.

To perform inter prediction on a current video block, motion estimationunit 204 may generate motion information for the current video block bycomparing one or more reference frames from buffer 213 to the currentvideo block. Motion compensation unit 205 may determine a predictedvideo block for the current video block based on the motion informationand decoded samples of pictures from buffer 213 other than the pictureassociated with the current video block.

Motion estimation unit 204 and motion compensation unit 205 may performdifferent operations for a current video block, for example, dependingon whether the current video block is in an I slice, a P slice, or a Bslice.

In some examples, motion estimation unit 204 may perform uni-directionalprediction for the current video block, and motion estimation unit 204may search reference pictures of list 0 or list 1 for a reference videoblock for the current video block. Motion estimation unit 204 may thengenerate a reference index that indicates the reference picture in list0 or list 1 that contains the reference video block and a motion vectorthat indicates a spatial displacement between the current video blockand the reference video block. Motion estimation unit 204 may output thereference index, a prediction direction indicator, and the motion vectoras the motion information of the current video block. Motioncompensation unit 205 may generate the predicted video block of thecurrent block based on the reference video block indicated by the motioninformation of the current video block.

In other examples, motion estimation unit 204 may perform bi-directionalprediction for the current video block, motion estimation unit 204 maysearch the reference pictures in list 0 for a reference video block forthe current video block and may also search the reference pictures inlist 1 for another reference video block for the current video block.Motion estimation unit 204 may then generate reference indexes thatindicate the reference pictures in list 0 and list 1 containing thereference video blocks and motion vectors that indicate spatialdisplacements between the reference video blocks and the current videoblock. Motion estimation unit 204 may output the reference indexes andthe motion vectors of the current video block as the motion informationof the current video block. Motion compensation unit 205 may generatethe predicted video block of the current video block based on thereference video blocks indicated by the motion information of thecurrent video block.

In some examples, motion estimation unit 204 may output a full set ofmotion information for decoding processing of a decoder.

In some examples, motion estimation unit 204 may do not output a fullset of motion information for the current video. Rather, motionestimation unit 204 may signal the motion information of the currentvideo block with reference to the motion information of another videoblock. For example, motion estimation unit 204 may determine that themotion information of the current video block is sufficiently similar tothe motion information of a neighboring video block.

In one example, motion estimation unit 204 may indicate, in a syntaxstructure associated with the current video block, a value thatindicates to the video decoder 300 that the current video block has thesame motion information as the another video block.

In another example, motion estimation unit 204 may identify, in a syntaxstructure associated with the current video block, another video blockand a motion vector difference (MVD). The motion vector differenceindicates a difference between the motion vector of the current videoblock and the motion vector of the indicated video block. The videodecoder 300 may use the motion vector of the indicated video block andthe motion vector difference to determine the motion vector of thecurrent video block.

As discussed above, video encoder 200 may predictively signal the motionvector. Two examples of predictive signaling techniques that may beimplemented by video encoder 200 include advanced motion vectorpredication (AMVP) and merge mode signaling.

Intra prediction unit 206 may perform intra prediction on the currentvideo block. When intra prediction unit 206 performs intra prediction onthe current video block, intra prediction unit 206 may generateprediction data for the current video block based on decoded samples ofother video blocks in the same picture. The prediction data for thecurrent video block may include a predicted video block and varioussyntax elements.

Residual generation unit 207 may generate residual data for the currentvideo block by subtracting (e.g., indicated by the minus sign) thepredicted video block(s) of the current video block from the currentvideo block. The residual data of the current video block may includeresidual video blocks that correspond to different sample components ofthe samples in the current video block.

In other examples, there may be no residual data for the current videoblock for the current video block, for example in a skip mode, andresidual generation unit 207 may not perform the subtracting operation.

Transform processing unit 208 may generate one or more transformcoefficient video blocks for the current video block by applying one ormore transforms to a residual video block associated with the currentvideo block.

After transform processing unit 208 generates a transform coefficientvideo block associated with the current video block, quantization unit209 may quantize the transform coefficient video block associated withthe current video block based on one or more quantization parameter (QP)values associated with the current video block.

Inverse quantization unit 210 and inverse transform unit 211 may applyinverse quantization and inverse transforms to the transform coefficientvideo block, respectively, to reconstruct a residual video block fromthe transform coefficient video block. Reconstruction unit 212 may addthe reconstructed residual video block to corresponding samples from oneor more predicted video blocks generated by the predication unit 202 toproduce a reconstructed video block associated with the current blockfor storage in the buffer 213.

After reconstruction unit 212 reconstructs the video block, loopfiltering operation may be performed reduce video blocking artifacts inthe video block.

Entropy encoding unit 214 may receive data from other functionalcomponents of the video encoder 200. When entropy encoding unit 214receives the data, entropy encoding unit 214 may perform one or moreentropy encoding operations to generate entropy encoded data and outputa bitstream that includes the entropy encoded data.

FIG. 36 is a block diagram illustrating an example of video decoder 300which may be video decoder 114 in the system 100 illustrated in FIG. 34.

The video decoder 300 may be configured to perform any or all of thetechniques of this disclosure. In the example of FIG. 36 , the videodecoder 300 includes a plurality of functional components. Thetechniques described in this disclosure may be shared among the variouscomponents of the video decoder 300. In some examples, a processor maybe configured to perform any or all of the techniques described in thisdisclosure.

In the example of FIG. 36 , video decoder 300 includes an entropydecoding unit 301, a motion compensation unit 302, an intra predictionunit 303, an inverse quantization unit 304, an inverse transformationunit 305, and a reconstruction unit 306 and a buffer 307. Video decoder300 may, in some examples, perform a decoding pass generally reciprocalto the encoding pass described with respect to video encoder 200 (e.g.,FIG. 35 ).

Entropy decoding unit 301 may retrieve an encoded bitstream. The encodedbitstream may include entropy coded video data (e.g., encoded blocks ofvideo data). Entropy decoding unit 301 may decode the entropy codedvideo data, and from the entropy decoded video data, motion compensationunit 302 may determine motion information including motion vectors,motion vector precision, reference picture list indexes, and othermotion information. Motion compensation unit 302 may, for example,determine such information by performing the AMVP and merge mode.

Motion compensation unit 302 may produce motion compensated blocks,possibly performing interpolation based on interpolation filters.Identifiers for interpolation filters to be used with sub-pixelprecision may be included in the syntax elements.

Motion compensation unit 302 may use interpolation filters as used byvideo encoder 20 during encoding of the video block to calculateinterpolated values for sub-integer pixels of a reference block. Motioncompensation unit 302 may determine the interpolation filters used byvideo encoder 200 according to received syntax information and use theinterpolation filters to produce predictive blocks.

Motion compensation unit 302 may uses some of the syntax information todetermine sizes of blocks used to encode frame(s) and/or slice(s) of theencoded video sequence, partition information that describes how eachmacroblock of a picture of the encoded video sequence is partitioned,modes indicating how each partition is encoded, one or more referenceframes (and reference frame lists) for each inter-encoded block, andother information to decode the encoded video sequence.

Intra prediction unit 303 may use intra prediction modes for examplereceived in the bitstream to form a prediction block from spatiallyadjacent blocks. Inverse quantization unit 303 inverse quantizes, i.e.,de-quantizes, the quantized video block coefficients provided in thebitstream and decoded by entropy decoding unit 301. Inverse transformunit 303 applies an inverse transform.

Reconstruction unit 306 may sum the residual blocks with thecorresponding prediction blocks generated by motion compensation unit202 or intra-prediction unit 303 to form decoded blocks. If desired, adeblocking filter may also be applied to filter the decoded blocks inorder to remove blockiness artifacts. The decoded video blocks are thenstored in buffer 307, which provides reference blocks for subsequentmotion compensation.

From the foregoing, it will be appreciated that specific embodiments ofthe presently disclosed technology have been described herein forpurposes of illustration, but that various modifications may be madewithout deviating from the scope of the invention. Accordingly, thepresently disclosed technology is not limited except as by the appendedclaims.

Some embodiments of the disclosed technology include making a decisionor determination to enable a video processing tool or mode. In anexample, when the video processing tool or mode is enabled, the encoderwill use or implement the tool or mode in the processing of a block ofvideo, but may not necessarily modify the resulting bitstream based onthe usage of the tool or mode. That is, a conversion from the block ofvideo to the bitstream representation of the video will use the videoprocessing tool or mode when it is enabled based on the decision ordetermination. In another example, when the video processing tool ormode is enabled, the decoder will process the bitstream with theknowledge that the bitstream has been modified based on the videoprocessing tool or mode. That is, a conversion from the bitstreamrepresentation of the video to the block of video will be performedusing the video processing tool or mode that was enabled based on thedecision or determination.

Some embodiments of the disclosed technology include making a decisionor determination to disable a video processing tool or mode. In anexample, when the video processing tool or mode is disabled, the encoderwill not use the tool or mode in the conversion of the block of video tothe bitstream representation of the video. In another example, when thevideo processing tool or mode is disabled, the decoder will process thebitstream with the knowledge that the bitstream has not been modifiedusing the video processing tool or mode that was enabled based on thedecision or determination.

Implementations of the subject matter and the functional operationsdescribed in this patent document can be implemented in various systems,digital electronic circuitry, or in computer software, firmware, orhardware, including the structures disclosed in this specification andtheir structural equivalents, or in combinations of one or more of them.Implementations of the subject matter described in this specificationcan be implemented as one or more computer program products, e.g., oneor more modules of computer program instructions encoded on a tangibleand non-transitory computer readable medium for execution by, or tocontrol the operation of, data processing apparatus. The computerreadable medium can be a machine-readable storage device, amachine-readable storage substrate, a memory device, a composition ofmatter effecting a machine-readable propagated signal, or a combinationof one or more of them. The term “data processing unit” or “dataprocessing apparatus” encompasses all apparatus, devices, and machinesfor processing data, including by way of example a programmableprocessor, a computer, or multiple processors or computers. Theapparatus can include, in addition to hardware, code that creates anexecution environment for the computer program in question, e.g., codethat constitutes processor firmware, a protocol stack, a databasemanagement system, an operating system, or a combination of one or moreof them.

A computer program (also known as a program, software, softwareapplication, script, or code) can be written in any form of programminglanguage, including compiled or interpreted languages, and it can bedeployed in any form, including as a stand-alone program or as a module,component, subroutine, or other unit suitable for use in a computingenvironment. A computer program does not necessarily correspond to afile in a file system. A program can be stored in a portion of a filethat holds other programs or data (e.g., one or more scripts stored in amarkup language document), in a single file dedicated to the program inquestion, or in multiple coordinated files (e.g., files that store oneor more modules, sub programs, or portions of code). A computer programcan be deployed to be executed on one computer or on multiple computersthat are located at one site or distributed across multiple sites andinterconnected by a communication network.

The processes and logic flows described in this specification can beperformed by one or more programmable processors executing one or morecomputer programs to perform functions by operating on input data andgenerating output. The processes and logic flows can also be performedby, and apparatus can also be implemented as, special purpose logiccircuitry, e.g., an FPGA (field programmable gate array) or an ASIC(application specific integrated circuit).

Processors suitable for the execution of a computer program include, byway of example, both general and special purpose microprocessors, andany one or more processors of any kind of digital computer. Generally, aprocessor will receive instructions and data from a read only memory ora random access memory or both. The essential elements of a computer area processor for performing instructions and one or more memory devicesfor storing instructions and data. Generally, a computer will alsoinclude, or be operatively coupled to receive data from or transfer datato, or both, one or more mass storage devices for storing data, e.g.,magnetic, magneto optical disks, or optical disks. However, a computerneed not have such devices. Computer readable media suitable for storingcomputer program instructions and data include all forms of nonvolatilememory, media and memory devices, including by way of examplesemiconductor memory devices, e.g., EPROM, EEPROM, and flash memorydevices. The processor and the memory can be supplemented by, orincorporated in, special purpose logic circuitry.

It is intended that the specification, together with the drawings, beconsidered exemplary only, where exemplary means an example. As usedherein, the use of “or” is intended to include “and/or”, unless thecontext clearly indicates otherwise.

While this patent document contains many specifics, these should not beconstrued as limitations on the scope of any invention or of what may beclaimed, but rather as descriptions of features that may be specific toparticular embodiments of particular inventions. Certain features thatare described in this patent document in the context of separateembodiments can also be implemented in combination in a singleembodiment. Conversely, various features that are described in thecontext of a single embodiment can also be implemented in multipleembodiments separately or in any suitable subcombination. Moreover,although features may be described above as acting in certaincombinations and even initially claimed as such, one or more featuresfrom a claimed combination can in some cases be excised from thecombination, and the claimed combination may be directed to a subcombination or variation of a sub combination.

Similarly, while operations are depicted in the drawings in a particularorder, this should not be understood as requiring that such operationsbe performed in the particular order shown or in sequential order, orthat all illustrated operations be performed, to achieve desirableresults. Moreover, the separation of various system components in theembodiments described in this patent document should not be understoodas requiring such separation in all embodiments.

Only a few implementations and examples are described and otherimplementations, enhancements and variations can be made based on whatis described and illustrated in this patent document.

1. A method of processing video data, comprising: making a firstdetermination, for a conversion between a current block of a video and abitstream of the video, about whether a sample in a neighboring block ofthe current block is in a same video region as the current block,wherein the neighboring block is located (1) above-left of the currentblock, (2) above-right of the current block, (3) below-left of thecurrent block, or (4) below-right of the current block; making a seconddetermination about whether the sample in the neighboring block isavailable for a coding tool that uses samples outside the current blockto the conversion of the current block, based on the firstdetermination, wherein the coding tool comprises an adaptive loop filtertool that comprises an adaptive loop filter classification processand/or an adaptive loop filtering process; and performing the conversionaccording to the first determination and the second determination. 2.The method of claim 1, wherein the video region comprises a slice. 3.The method of claim 1, wherein the sample in the neighboring block isconsidered to be unavailable for the coding tool in case (1) theneighboring block and the current block are in different video regions,and (2) accessing samples across different video regions of the video isdisabled for the coding tool.
 4. The method of claim 3, wherein thesample in the neighboring block is located below-right of the currentblock, and wherein when the below-right neighboring block and thecurrent block are in different video regions, and accessing samplesacross different video regions of the video is disabled for the codingtool, a variable flag clip TopLeftFlag is set equal to true and thesample in the above-left neighboring block is considered to beunavailable based on a value of the clip TopLeftFlag is true.
 5. Themethod of claim 3, wherein the sample in the neighboring block islocated below-right of the current block, and wherein when thebelow-right neighboring block and the current block are in differentvideo regions, and accessing samples across different video regions ofthe video is disabled for the coding tool, a variable flagclipBottomRightFlag is set equal to true and the sample in thebelow-right neighboring block is considered to be unavailable based on avalue of the clipBottomRightFlag is true.
 6. The method of claim 3,wherein a syntax element is included in the bitstream to indicatewhether accessing samples across different video regions is disabled. 7.The method of claim 6, wherein the video region is a slice, the syntaxelement in a picture parameter set specifies whether in-loop filteringoperations are allowed to be performed across slice boundaries inpictures.
 8. The method of claim 6, further comprising applying apadding process in response to the sample in the neighboring block beingunavailable for the coding tool.
 9. The method of claim 1, wherein theconversion includes encoding the video into the bitstream.
 10. Themethod of claim 1, the conversion includes decoding the video from thebitstream.
 11. An apparatus for processing video data comprising aprocessor and a non-transitory memory with instructions thereon, whereinthe instructions upon execution by the processor, cause the processorto: make a first determination, for a conversion between a current blockof a video and a bitstream of the video, about whether a sample in aneighboring block of the current block is in a same video region as thecurrent block, wherein the neighboring block is located (1) above-leftof the current block, (2) above-right of the current block, (3)below-left of the current block, or (4) below-right of the currentblock; make a second determination about whether the sample in theneighboring block is available for a coding tool that uses samplesoutside the current block to the conversion of the current block, basedon the first determination, wherein the coding tool comprises anadaptive loop filter tool that comprises an adaptive loop filterclassification process and/or an adaptive loop filtering process; andperform the conversion according to the first determination and thesecond determination.
 12. The apparatus of claim 11, wherein the videoregion comprises a slice; and wherein the sample in the neighboringblock is considered to be unavailable for the coding tool in case (1)the neighboring block and the current block are in different videoregions, and (2) accessing samples across different video regions of thevideo is disabled for the coding tool.
 13. The apparatus of claim 12,wherein the sample in the neighboring block is located below-right ofthe current block, and wherein when the below-right neighboring blockand the current block are in different video regions, and accessingsamples across different video regions of the video is disabled for thecoding tool, a variable flag clipTopLeftFlag is set equal to true andthe sample in the above-left neighboring block is considered to beunavailable based on a value of the clipTopLeftFlag is true; oralternatively, wherein the sample in the neighboring block is locatedbelow-right of the current block, and wherein when the below-rightneighboring block and the current block are in different video regions,and accessing samples across different video regions of the video isdisabled for the coding tool, a variable flag clipBottomRightFlag is setequal to true and the sample in the below-right neighboring block isconsidered to be unavailable based on a value of the clipBottomRightFlagis true.
 14. The apparatus of claim 12, wherein a syntax element isincluded in the bitstream to indicate whether accessing samples acrossdifferent video regions is disabled; wherein the video region is aslice, the syntax element in a picture parameter set specifies whetherin-loop filtering operations are allowed to be performed across sliceboundaries in pictures; and wherein the processor is further caused toapply a padding process in response to the sample in the neighboringblock being unavailable for the coding tool.
 15. A non-transitorycomputer-readable storage medium storing instructions that cause aprocessor to: make a first determination, for a conversion between acurrent block of a video and a bitstream of the video, about whether asample in a neighboring block of the current block is in a same videoregion as the current block, wherein the neighboring block is located(1) above-left of the current block, (2) above-right of the currentblock, (3) below-left of the current block, or (4) below-right of thecurrent block; make a second determination about whether the sample inthe neighboring block is available for a coding tool that uses samplesoutside the current block to the conversion of the current block, basedon the first determination, wherein the coding tool comprises anadaptive loop filter tool that comprises an adaptive loop filterclassification process and/or an adaptive loop filtering process; andperform the conversion according to the first determination and thesecond determination.
 16. The non-transitory computer-readable storagemedium of claim 15, wherein the video region comprises a slice; andwherein the sample in the neighboring block is considered to beunavailable for the coding tool in case (1) the neighboring block andthe current block are in different video regions, and (2) accessingsamples across different video regions of the video is disabled for thecoding tool; wherein the sample in the neighboring block is locatedbelow-right of the current block, and wherein when the below-rightneighboring block and the current block are in different video regions,and accessing samples across different video regions of the video isdisabled for the coding tool, a variable flag clipTopLeftFlag is setequal to true and the sample in the above-left neighboring block isconsidered to be unavailable based on a value of the clipTopLeftFlag istrue; or alternatively, wherein the sample in the neighboring block islocated below-right of the current block, and wherein when thebelow-right neighboring block and the current block are in differentvideo regions, and accessing samples across different video regions ofthe video is disabled for the coding tool, a variable flagclipBottomRightFlag is set equal to true and the sample in thebelow-right neighboring block is considered to be unavailable based on avalue of the clipBottomRightFlag is true.
 17. The non-transitorycomputer-readable storage medium of claim 16, wherein a syntax elementis included in the bitstream to indicate whether accessing samplesacross different video regions is disabled; wherein the video region isa slice, the syntax element in a picture parameter set specifies whetherin-loop filtering operations are allowed to be performed across sliceboundaries in pictures; and wherein the processor is further caused toapply a padding process in response to the sample in the neighboringblock being unavailable for the coding tool.
 18. A non-transitorycomputer-readable recording medium storing a bitstream of a video whichis generated by a method performed by a video processing apparatus,wherein the method comprises: making a first determination, for acurrent block of a video, about whether a sample in a neighboring blockof the current block is in a same video region as the current block,wherein the neighboring block is located (1) above-left of the currentblock, (2) above-right of the current block, (3) below-left of thecurrent block, or (4) below-right of the current block; making a seconddetermination about whether the sample in the neighboring block isavailable for a coding tool that uses samples outside the current blockfor generating the bitstream for the current block, based on the firstdetermination, wherein the coding tool comprises an adaptive loop filtertool that comprises an adaptive loop filter classification processand/or an adaptive loop filtering process; and generating the bitstreamaccording to the first determination and the second determination. 19.The non-transitory computer-readable recording medium of claim 18,wherein the sample in the neighboring block is located below-right ofthe current block, and wherein when the below-right neighboring blockand the current block are in different video regions, and accessingsamples across different video regions of the video is disabled for thecoding tool, a variable flag clipTopLeftFlag is set equal to true andthe sample in the above-left neighboring block is considered to beunavailable based on a value of the clipTopLeftFlag is true; oralternatively, wherein the sample in the neighboring block is locatedbelow-right of the current block, and wherein when the below-rightneighboring block and the current block are in different video regions,and accessing samples across different video regions of the video isdisabled for the coding tool, a variable flag clipBottomRightFlag is setequal to true and the sample in the below-right neighboring block isconsidered to be unavailable based on a value of the clipBottomRightFlagis true.
 20. The non-transitory computer-readable recording medium ofclaim 19, wherein a syntax element is included in the bitstream toindicate whether accessing samples across different video regions isdisabled; wherein the video region is a slice, the syntax element in apicture parameter set specifies whether in-loop filtering operations areallowed to be performed across slice boundaries in pictures; and whereinthe method further comprises applying a padding process in response tothe sample in the neighboring block being unavailable for the codingtool.